sendData method

Future<void> sendData(
  1. String message
)

Send text message on existing text room using data channel with same label as specified during initDataChannel() method call.

for now janus text room only supports text as string although with normal data channel api we can send blob or Uint8List if we want.

Implementation

Future<void> sendData(String message) async {
  // if (message != null) {
  if (webRTCHandle!.peerConnection != null) {
    this._context._logger.finest('before send RTCDataChannelMessage');
    if (webRTCHandle!.dataChannel[_context._dataChannelDefaultLabel] ==
        null) {
      throw Exception(
          "You Must  call initDataChannel method! before you can send any data channel message");
    }
    RTCDataChannel dataChannel =
        webRTCHandle!.dataChannel[_context._dataChannelDefaultLabel]!;
    if (dataChannel.state == RTCDataChannelState.RTCDataChannelOpen) {
      return await dataChannel.send(RTCDataChannelMessage(message));
    }
  } else {
    throw Exception(
        "You Must Initialize Peer Connection followed by initDataChannel()");
  }
  // } else {
  //   throw Exception("message must be provided!");
  // }
}