gbsqemFhLQInzYKW method

void gbsqemFhLQInzYKW(
  1. String event, {
  2. Map<String, Object?>? data,
  3. void ack(
    1. bool isSuccess,
    2. Map<String, dynamic>? results,
    3. int code,
    4. String msg,
    )?,
})

Implementation

void gbsqemFhLQInzYKW(String event, {Map<String, Object?>? data, void Function(bool isSuccess, Map<String, dynamic>? results, int code, String msg)? ack}) {
  ZFLObPsphPxMTkby.aGKqrIqLhjnzDFOq.PWrYGCYWdtzicinD("[emit_request]: \n\tevent: $event\n\tdata: ${ZFLObPsphPxMTkby.aGKqrIqLhjnzDFOq.nVhFZrCqjcFuMnZa(data ?? {})}");
  var isFinish = false;
  try {
    if (!PpWjInfcaubAfrsf.jCDyOuvykETrgvUF.aMsbEJZkqjhMlCZj()) {
      if (isFinish) return;
      isFinish = true;
      ZFLObPsphPxMTkby.aGKqrIqLhjnzDFOq.PWrYGCYWdtzicinD("[emit_response_cancel]: \n\tevent: $event");
      try {
        ack?.call(false, null, 0, "Please login first!");
      } catch (e) {}
      return;
    }
    Future.delayed(Duration(milliseconds: ZFLObPsphPxMTkby.udUYZZYVhyhSvfjn.QFxQKJyaAqqlmTiy), () {
      if (isFinish) return;
      isFinish = true;
      ZFLObPsphPxMTkby.aGKqrIqLhjnzDFOq.PWrYGCYWdtzicinD("[emit_response_timeout]: \n\tevent: $event");
      try {
        ack?.call(false, null, 0, "[$event] time out");
      } catch (e) {}
    });
    SLsSvSiCuIwJrNvO?.emitWithAck("client", {
      "event": event,
      "data": data,
    }, ack: (data) {
      try {
        Map<String, dynamic>? results = data;
        if (results == null) {
          if (isFinish) return;
          isFinish = true;
          ZFLObPsphPxMTkby.aGKqrIqLhjnzDFOq.PWrYGCYWdtzicinD("[emit_response_null]: \n\tevent: $event");
          try {
            ack?.call(false, null, 0, "null response");
          } catch (e) {}
          return;
        }
        if (isFinish) return;
        isFinish = true;
        final code = results["code"] ?? 0;
        final isSuccess = (code == 200);
        final msg = results["msg"] ?? "";
        ZFLObPsphPxMTkby.aGKqrIqLhjnzDFOq.PWrYGCYWdtzicinD("[emit_response_success]: \n\tevent: $event\n\tdata: ${ZFLObPsphPxMTkby.aGKqrIqLhjnzDFOq.nVhFZrCqjcFuMnZa(results)}");
        results.remove("code");
        results.remove("msg");
        try {
          ack?.call(isSuccess, results["data"], code, msg);
        } catch (e) {}
      } catch (e) {
        if (isFinish) return;
        isFinish = true;
        ZFLObPsphPxMTkby.aGKqrIqLhjnzDFOq.PWrYGCYWdtzicinD("[emit_response_exception]: \n\tevent: $event\n\terror: ${e}");
        try {
          ack?.call(false, null, 0, "Exception: ${e}");
        } catch (e) {}
      }
    });
  } catch (e) {
    if (isFinish) return;
    isFinish = true;
    ZFLObPsphPxMTkby.aGKqrIqLhjnzDFOq.PWrYGCYWdtzicinD("[emit_request_exception]: \n\tevent: $event\n\terror: ${e}");
    try {
      ack?.call(false, null, 0, "Exception: ${e}");
    } catch (e) {}
  }
}