connectViewerApp method

dynamic connectViewerApp(
  1. List<String> sessionIDViewAppList
)

Implementation

connectViewerApp(List<String> sessionIDViewAppList) async {
  if (sessionIDViewAppList.length == 1) {
    iscallonetomany = true;
    callSessionUUID = sessionIDViewAppList.first;
    _peerConnection =
        await _createPeerConnectiononetomanycallreceive("video", "call");
    RTCSessionDescription description = await _peerConnection!.createOffer({
      "mandatory": {
        "OfferToReceiveAudio": true,
        "OfferToReceiveVideo": true,
      }
    }).then((value) {
      print("this is Description875485 $value");
      return value;
    }).catchError((onError) {
      print("this is error on create offer111133 $onError");
    });
    _peerConnection?.setLocalDescription(description).then((value) {
      print("ths is on Successfully set7771");
      return value;
    }).catchError((onError) {
      print('this is on Error set localDes094958');
    });

    Map<String, dynamic> JsonData = {
      "type": "request",
      "requestType": "publicURL",
      "sdpOffer": description.sdp.toString(),
      "requestId": callSessionUUID,
      "sessionUuid": callSessionUUID,
      "responseCode": 200,
      "responseMessage": "accepted"
    };
    print("this is json on create offer $JsonData");
    _socket?.send(JsonData);
  } else {
    ismultisession = true;
    iscallonetomany = true;
    callSessionUUID = sessionIDViewAppList.first;
    screenSessionUUID = sessionIDViewAppList[1];

    _peerConnection =
        await _createPeerConnectiononetomanycallreceive("video", "call");

    _peerConnectionformultisession =
        await _createPeerConnectiononetomanycallreceive("video", "screen");

    RTCSessionDescription description = await _peerConnection!.createOffer({
      "mandatory": {
        "OfferToReceiveAudio": true,
        "OfferToReceiveVideo": true,
      }
    }).then((value) {
      print("this is Description875485 $value");
      return value;
    }).catchError((onError) {
      print("this is error on create offer111133 $onError");
    });
    _peerConnection?.setLocalDescription(description).then((value) {
      print("ths is on Successfully set7771");
      return value;
    }).catchError((onError) {
      print('this is on Error set localDes094958');
    });

    RTCSessionDescription description1 =
        await _peerConnectionformultisession!.createOffer({
      "mandatory": {
        "OfferToReceiveAudio": true,
        "OfferToReceiveVideo": true,
      }
    }).then((value) {
      print("this is Description030404 $value");
      return value;
    }).catchError((onError) {
      print("this is error on create offer0101 $onError");
    });
    _peerConnectionformultisession
        ?.setLocalDescription(description1)
        .then((value) {
      print("ths is on Successfully 06956");
      return value;
    }).catchError((onError) {
      print('this is on Error set 3-290');
    });

    Map<String, dynamic> JsonData = {
      "type": "request",
      "requestType": "publicURL",
      "sdpOffer": description.sdp.toString(),
      "requestId": callSessionUUID,
      "sessionUuid": callSessionUUID,
      "responseCode": 200,
      "responseMessage": "accepted"
    };
    print("this is json on create offer $JsonData");
    _socket?.send(JsonData);

    final Map<String, dynamic> _offerJson1 = {
      "type": "request",
      "requestType": "publicURL",
      "requestId": screenSessionUUID,
      "sessionUuid": screenSessionUUID,
      "responseCode": 200,
      "responseMessage": "accepted",
      "sdpOffer": description1.sdp.toString()
    };
    _socket?.send(_offerJson1);
  }
}