|
|
@ -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()); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|