Compare commits

..

No commits in common. "525e10badc52ae944abcd482f9af2353916674c3" and "b6b6e41e8bd894cc9267fabd62bf3e3785a5226f" have entirely different histories.

1 changed files with 8 additions and 12 deletions

View File

@ -45,7 +45,6 @@ class LoginSocket{
connect() async {
socket?.close();
socket = await Socket.connect(url, port, timeout: const Duration(seconds: 30));
heartTime = DateTime.now().millisecondsSinceEpoch;
socket?.listen((event) {
@ -59,11 +58,6 @@ class LoginSocket{
//
if (data['op'] == 4){
try{
//
heartTime = DateTime.now().millisecondsSinceEpoch;
//
int time = data['time'];
time = DateTime.now().millisecondsSinceEpoch - time;
if(time> (3 * 60 * 1000) ){ // > 3
@ -113,17 +107,17 @@ class LoginSocket{
///
heartbeat(){
DateTime now = DateTime.now();
int timestamp = now.millisecondsSinceEpoch; //
heartTime = timestamp;
Timer(const Duration(seconds: 20), () async {
final time = DateTime.now().millisecondsSinceEpoch - heartTime;
if(time > (3 * 60 * 1000) ){ // > 3
socketError();
return;
if (socket == null){
//
await connect();
}
heartbeat();
Map map = {
"op": 3,
};
@ -131,6 +125,8 @@ class LoginSocket{
socket?.add(dataMake(map));
socket?.flush();
heartbeat();
});
}