writeMessage method
Writes the specified HubMessage to a string or ArrayBuffer and returns it.
If transferFormat is 'Text', the result of this method will be a string, otherwise it will be an ArrayBuffer.
message
The message to write.
returns A string or ArrayBuffer containing the serialized representation of the message.
Implementation
@override
Object writeMessage(HubMessageBase message) {
final messageType = message.type;
switch (messageType) {
case MessageType.Invocation:
return _writeInvocation(message as InvocationMessage);
case MessageType.StreamInvocation:
return _writeStreamInvocation(message as StreamInvocationMessage);
case MessageType.StreamItem:
return _writeStreamItem(message as StreamItemMessage);
case MessageType.Completion:
return _writeCompletion(message as CompletionMessage);
case MessageType.Ping:
return _writePing();
case MessageType.CancelInvocation:
return _writeCancelInvocation(message as CancelInvocationMessage);
default:
throw GeneralError("Invalid message type.");
}
//throw GeneralError("Converting '${message.type}' is not implemented.");
}