packetParser method

void packetParser(
  1. WsPacket packet
)

Implementation

void packetParser(WsPacket packet) {
  if (packet is WsEvent) {
    eventParser(packet);
  } else if (packet is WsWebRTCUp) {
    logTime("WsWebRTCUp packet sender= ${packet.sender.toString()}", TAG);
    _janusResponseCallback?.onWebRTCUpReceived(packet.sender);
  } else if (packet is WsMedia) {
    logTime(
        "WsMedia packet type= ${packet.type}, receiving= ${packet.receiving.toString()}",
        TAG);
    _janusResponseCallback?.onMediaReceived(packet.type, packet.receiving);
  } else if (packet is WsHangUp) {
    logTime("WsHangUp packet reason= ${packet.reason!}", TAG);
    _janusResponseCallback?.onHangUp(packet.reason);
  } else if (packet is WsSlowLink) {
    logTime("WsSlowLink packet uplink= ${packet.uplink}", TAG);
    _janusResponseCallback?.onSlowLinkReceived(packet.uplink, packet.lost);
  } else if (packet is WsDataPacket) {
    if (packet.isGetParticipant()) {
      List<Map<String, Object>> participants =
          packet.plugindata!.data.participants;
      _janusResponseCallback?.onGetOnlineParticipants(
          convertParticipantListToArray(participants));
    } else if (packet.isVideoRoomEvent()) {
      _janusResponseCallback?.onVideoRoomEvent(packet.plugindata!.data.error);
    }
  } else if (packet is WsError) {
    _janusResponseCallback?.onEventError(
        packet.error.reason, packet.error.code);
  }
}