Browse Source

socketclient heartbeat

wr_202303
zsw 4 months ago
parent
commit
6711b8a079
  1. 6
      lib/im/SocketClient.dart

6
lib/im/SocketClient.dart

@ -54,11 +54,11 @@ class SocketClient {
} }
heartbeat() { heartbeat() {
Timer.periodic(const Duration(milliseconds: 3000), (timer) { Timer.periodic(const Duration(milliseconds: 30000), (timer) {
debugPrint("heartbeat: ${DateTime.now().millisecondsSinceEpoch}"); debugPrint("heartbeat: ${DateTime.now().millisecondsSinceEpoch}");
Uint8List data = utf8.encode(jsonEncode({"heartbeat": DateTime.now().millisecondsSinceEpoch})); Uint8List data = utf8.encode(jsonEncode({"heartbeat": DateTime.now().millisecondsSinceEpoch}));
MsgData msgData = MsgData(to: "0", from: userId, type: MsgType.TEXT, data: data); MsgData msgData = MsgData(from: userId, type: MsgType.TEXT, data: data);
final proto2 = Proto(5, 1, msgData.writeToBuffer()); final proto2 = Proto(3, 1, msgData.writeToBuffer());
_socket.add(proto2.toBytes()); _socket.add(proto2.toBytes());
}); });
} }

Loading…
Cancel
Save