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这个数字,怎么能获取具体是哪个用户下线了呢???
添加回答
举报
0/150
提交
取消