send method

  1. @override
Future<void> send({
  1. required List<int> value,
  2. Duration durationTimeOut = const Duration(minutes: 1),
  3. Duration durationDelay = const Duration(milliseconds: 1),
})
override

Implementation

@override
Future<void> send({
  required List<int> value,
  Duration durationTimeOut = const Duration(minutes: 1),
  Duration durationDelay = const Duration(milliseconds: 1),
}) async {
  DateTime dateTime = DateTime.now().add(durationTimeOut);
  await Future.delayed(durationDelay);
  while (true) {
    await Future.delayed(Duration(microseconds: 10));
    if (dateTime.isBefore(DateTime.now())) {
      throw SocketError({
        "@type": "socketError",
        "message": "send_data_time_out",
        "description": "Send Data time out "
      });
    }

    if (isConnect) {
      break;
    }
  }
  return socket.add(value);
}