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 SignalRException(
message: "Invalid message type.",
type: SignalRExceptionType.invalidPayload);
}
}