createAnswer method

dynamic createAnswer(
  1. dynamic refID
)

Implementation

createAnswer(refID) async {
  if (iscallonetoone == true || iscallonetomany == true) {
    callend = false;

    starttime = DateTime.now();
    inCall = true;
    try {
      if (ismultisession == true) {
        print("i am here in multi session create answer");
        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');
        });
        // callRequestid=_generateMd5(
        //       DateTime.now().millisecondsSinceEpoch.toString() +
        //           tenantID +
        //           ref_id);
        // print("this is call request idddddddd $callRequestid");
        final Map<String, dynamic> _offerJson = {
          "type": "request",
          "requestId": _generateMd5(
              DateTime.now().millisecondsSinceEpoch.toString() +
                  tenantID +
                  ref_id!),
          "sessionUuid":
              //sessionUUID,
              callSessionUUID,
          "requestType": "session_invite",
          "responseCode": 200,
          "responseMessage": "accepted",
          "sdpOffer": description.sdp.toString()
        };
        print("this is offer json in one to one  $_offerJson");
        _socket?.send(_offerJson);
        // screenRequesid= _generateMd5(
        //       DateTime.now().millisecondsSinceEpoch.toString() +
        //           tenantID +
        //           ref_id);
        final Map<String, dynamic> _offerJson1 = {
          "type": "request",
          "requestId": _generateMd5(
              DateTime.now().millisecondsSinceEpoch.toString() +
                  tenantID +
                  ref_id!),
          "sessionUuid":
              //multisessionuuid,
              screenSessionUUID,
          "requestType": "session_invite",
          "responseCode": 200,
          "responseMessage": "accepted",
          "sdpOffer": description1.sdp.toString()
        };
        print("this is offer json in one to one......  $_offerJson1");
        _socket?.send(_offerJson1);
      } else {
        //  _peerConnection =
        //   await _createPeerConnectiononetoone("video");
        print("this is peerConnectionnnnnnn $_peerConnection");

        RTCSessionDescription description =
            await _peerConnection!.createOffer({
          "mandatory": {
            "OfferToReceiveAudio": true,
            "OfferToReceiveVideo": true,
          }
        }).then((value) {
          print("this is  8r67 $value");
          return value;
        }).catchError((onError) {
          print("this is error 059540 $onError");
        });
        _peerConnection?.setLocalDescription(description).then((value) {
          print("ths is on o3w936");
          return value;
        }).catchError((onError) {
          print('this is on Error 4975');
        });
        final Map<String, dynamic> _offerJson = {
          "type": "request",
          "requestId": _generateMd5(
              DateTime.now().millisecondsSinceEpoch.toString() +
                  tenantID +
                  ref_id!),
          "sessionUuid": callSessionUUID,
          "requestType": "session_invite",
          "responseCode": 200,
          "responseMessage": "accepted",
          "sdpOffer": description.sdp.toString()
        };
        print("this is offer json in one to one  $_offerJson");
        _socket?.send(_offerJson);
      }
    } catch (e) {
      print("this is error in create answer$e");
    }
  } else {
    print("this is name $refID  ${rtcPeerConnectionList[ref_id]}");

    try {
      print(
          "this is peer connection in create answer ${rtcPeerConnectionList[ref_id]}");
      RTCSessionDescription? description =
          await rtcPeerConnectionList[ref_id]?.createOffer({
        "mandatory": {
          "OfferToReceiveAudio": true,
          "OfferToReceiveVideo": true,
        }
      }).then((value) {
        print("this is Description sdp767 $value");
        return value;
      }).catchError((onError) {
        print("this is error on create offer0000 $onError");
      });
      if (rtcPeerConnectionList[ref_id] != null) {
        rtcPeerConnectionList[ref_id]!
            .setLocalDescription(description!)
            .then((value) {
          print("ths is on Successfully set064 ${description.sdp}");
          return value;
        }).catchError((onError) {
          print('this is on Error set localDes453 $onError');
        });
      }

      final Map<String, dynamic> _offerJson = {
        "type": "request",
        "requestId": _generateMd5(
            DateTime.now().millisecondsSinceEpoch.toString() +
                tenantID +
                ref_id!),
        "sessionUuid": callSessionUUID,
        "requestType": "session_invite",
        "responseCode": 200,
        "responseMessage": "accepted",
        "sdpOffer": description?.sdp.toString()
      };
      print(
          "these are on participants icecandidates #!!!!!!!!!!!!122 $_offerJson");
      _socket?.send(_offerJson);
    } catch (e) {
      print("this is error $e");
    }
  }
}