send method

void send(
  1. RelayConnectivity relayConnectivity,
  2. ClientMsg msg
)

sends a ClientMsg to relay transport sink, throw an error if relay not connected

Implementation

void send(RelayConnectivity relayConnectivity, ClientMsg msg) async {
  if (relayConnectivity.relayTransport == null) {
    throw Exception("relay not connected");
  }

  /// wait until rdy
  await relayConnectivity.relayTransport!.ready;

  final String encodedMsg = jsonEncode(msg.toJson());
  _sendRaw(relayConnectivity, encodedMsg);
}