setConnectionChecker method

void setConnectionChecker({
  1. Duration timeout = const Duration(seconds: 12),
  2. Duration interval = const Duration(seconds: 45),
  3. required Function retry,
})

Implementation

void setConnectionChecker(
    {Duration timeout = const Duration(seconds: 12),
    Duration interval = const Duration(seconds: 45),
    required Function retry}) {
  socketService.setConnectionChecker(
      timeout: timeout,
      deviceQueryDeviceName: '',
      interval: interval,
      shouldCheck :()=>modded,
      useRetryResponse: (v) {
        if (v is DeviceStatusResponse) {
          if (v.result.toLowerCase() == "ok" || v.result.toLowerCase() == "") {
            // print(deviceStatusRes.status.map((e) => e.toXML()).toList());
            if (v.status.where((element) => element.toXML().contains("${getType.name}Status")).isNotEmpty) {
              // print("Status DETECTED");
              deviceParameter.status = v.status.firstWhere((element) => element.toXML().contains("${getType.name}Status"));
              CUPPS().notifier!();
              return CuppsCommandResponse(status: true, msg: "Device :$deviceName Status Refreshed");
            }
          }
        }
      },
      retryFunction: () {
        if (!isPrinting) {
          retry();
        }
      });
}