1.nodejs里用的是ws那个库
2.用户断开连接的代码是这样写的
var WebSocketServer = require('D:/0.ProgramFiles/2.Devel/4.NodeJs/node_modules/ws').Server;
var wss = new WebSocketServer({port: 8888});
var userList = [];
wss.on('connection', function (ws,req) {
// console.log(req.connection.remoteAddress)
console.log(getUUID());
ws.on('message', function (message) {
console.log("收到消息:" + message);
wss.clients.forEach(function each(client) {
client.send(message);
});
});
ws.on('close', function (message) {
console.log(id);
});
});
现在的情况是:
用户直接关闭前台网页后,后端只能收到1001这个数字,
怎么能获取具体是哪个用户下线了呢???
相关分类