connect method

Future<void> connect(
  1. dynamic projectid,
  2. dynamic completeAddress
)

Implementation

Future<void> connect(projectid, completeAddress) async {

      print("i am in connect function in sdk");
      print(
          "This is project id $projectid complete address $completeAddress");
      completeAddresssForOne2Many = completeAddress;
      projectID = projectid;
        await getInternetStatus().then((value) async {
    print("this is valuuueee $value");
    if (value) {
      _socket = WebSocketConnection(url: completeAddress);
      try {
        _socket?.onOpen = () {
          print("socket is open");
        onConnect?.call("connected");
        };
      } catch (e) {
        print("this is error in socket opening $e");
      }
      try {
        _socket?.onMessage = (message) {
          _onMessage(json.decode(message));
        };
      } catch (e) {
        print("this is error on decode or else $e");
      }
      _socket?.onError = () {
        print('this is onerrrrr');
      };

      _socket?.onClose = (int? code, String? reason) {
        isCallStart = 0;
        print("this is onclose socket $_socket");
        timer?.cancel();
        if (reason == null) {
          onError?.call(code!, "no reason");
        } else {
          onError?.call(code!, reason);
        }
      };

      await _socket?.connect();
    } else {
      print("here in falseeee $_socket");
      // onError?.call()
      //internetConnectivityCallBack?.call("Disconnected");
      //onError?.call(1000,"no internet connection");
    }
  }).catchError((onError) {
    print("this is onError of internet connection $onError");
  });
}