sendMessage method
Send a channel on the socket.
Used internall to send prepared message. If you need to send a message on a channel, you would usually use PhoenixChannel.push instead.
Implementation
Future<Message> sendMessage(Message message) {
if (_ws?.sink == null) {
return Future.error(PhoenixException(
socketClosed: PhoenixSocketCloseEvent(),
));
}
if (message.ref == null) {
throw ArgumentError.value(
message,
'message',
'does not contain a ref',
);
}
_addToSink(_options.serializer.encode(message));
return (_pendingMessages[message.ref!] = Completer<Message>()).future;
}