Commit 224f8da0 authored by nanahira's avatar nanahira

fix node 18 closed problem

parent 747b78c7
......@@ -852,7 +852,7 @@ CLIENT_kick = global.CLIENT_kick = (client) ->
if !client
return false
client.system_kicked = true
if settings.modules.reconnect.enabled and client.closed
if settings.modules.reconnect.enabled and client.isClosed
if client.server and !client.had_new_reconnection
room = ROOM_all[client.rid]
if room
......@@ -1796,8 +1796,8 @@ netRequestHandler = (client) ->
# 释放处理
closeHandler = (error) ->
#log.info "client closed", client.name, had_error
#log.info "disconnect", client.ip, ROOM_connected_ip[client.ip]
log.info "client closed", client.name, error, client.closed
log.info "disconnect", client.ip, ROOM_connected_ip[client.ip]
if client.closed
return
room=ROOM_all[client.rid]
......@@ -1810,7 +1810,7 @@ netRequestHandler = (client) ->
CLIENT_heartbeat_unregister(client)
if room
if !CLIENT_reconnect_register(client, client.rid, error)
room.disconnect(client)
room.disconnect(client, error)
else if !client.had_new_reconnection
SERVER_kick(client.server)
return
......@@ -1818,13 +1818,13 @@ netRequestHandler = (client) ->
if client.isWs
client.on 'close', (code, reason) ->
closeHandler()
else
client.on 'close', (had_error) ->
closeHandler(had_error ? 'unknown' : undefined)
client.on 'timeout', ()->
unless settings.modules.reconnect.enabled and (disconnect_list[CLIENT_get_authorize_key(client)] or client.had_new_reconnection)
client.destroy()
return
else
client.on 'close', (had_error) ->
closeHandler(had_error ? 'unknown' : undefined)
client.on 'error', closeHandler
......
......@@ -1119,7 +1119,7 @@
return false;
}
client.system_kicked = true;
if (settings.modules.reconnect.enabled && client.closed) {
if (settings.modules.reconnect.enabled && client.isClosed) {
if (client.server && !client.had_new_reconnection) {
room = ROOM_all[client.rid];
if (room) {
......@@ -2423,8 +2423,8 @@
// 释放处理
closeHandler = function(error) {
var room;
//log.info "client closed", client.name, had_error
//log.info "disconnect", client.ip, ROOM_connected_ip[client.ip]
log.info("client closed", client.name, error, client.closed);
log.info("disconnect", client.ip, ROOM_connected_ip[client.ip]);
if (client.closed) {
return;
}
......@@ -2440,7 +2440,7 @@
}
if (room) {
if (!CLIENT_reconnect_register(client, client.rid, error)) {
room.disconnect(client);
room.disconnect(client, error);
}
} else if (!client.had_new_reconnection) {
SERVER_kick(client.server);
......@@ -2450,17 +2450,17 @@
client.on('close', function(code, reason) {
return closeHandler();
});
client.on('timeout', function() {
if (!(settings.modules.reconnect.enabled && (disconnect_list[CLIENT_get_authorize_key(client)] || client.had_new_reconnection))) {
client.destroy();
}
});
} else {
client.on('close', function(had_error) {
return closeHandler(had_error != null ? had_error : {
'unknown': void 0
});
});
client.on('timeout', function() {
if (!(settings.modules.reconnect.enabled && (disconnect_list[CLIENT_get_authorize_key(client)] || client.had_new_reconnection))) {
client.destroy();
}
});
}
client.on('error', closeHandler);
server.on('close', function(had_error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment