save commid to socket in addition to usid
This commit is contained in:
parent
a33572c240
commit
e88d063184
@ -50,7 +50,8 @@ module.exports = {
|
||||
if (typeof _passtokenSource?.usid === 'string') {
|
||||
socket.appkey = _passtokenSource.appkey
|
||||
socket.usid = _passtokenSource.usid
|
||||
socket.skid = socket.skid || _passtokenSource.clid || 'skid' + crypto.randomBytes(16).toString('hex') // 注意,skid 这个名字 仅限在本文件内使用,在外部都使用 clid (client id)
|
||||
socket.commid = _passtokenSource.commid
|
||||
socket.skid = _passtokenSource.clid || socket.skid || 'skid' + crypto.randomBytes(16).toString('hex') // 注意,skid 这个名字 仅限在本文件内使用,在外部都使用 clid (client id)
|
||||
// my.socketPool[socket.skid] = socket
|
||||
console.log(
|
||||
{
|
||||
@ -81,14 +82,14 @@ module.exports = {
|
||||
})
|
||||
})
|
||||
|
||||
my.wsServer.on('close', () => {})
|
||||
my.wsServer.on('close', () => { })
|
||||
|
||||
// 一个全局的 heartbeat,不必给每个 socket 一个 heartbeat
|
||||
if (heartbeat) {
|
||||
console.log('WebSocket_heartbeat: starting...')
|
||||
setInterval(() => {
|
||||
my.wsServer.clients.forEach((socket) => {
|
||||
console.log('WebSocket_heartbeat: ', { usid: socket.usid, skid: socket.skid, appkey: socket.appkey, readyState: socket.readyState })
|
||||
console.log('WebSocket_heartbeat: ', { usid: socket.usid, commid: socket.commid, skid: socket.skid, appkey: socket.appkey, readyState: socket.readyState })
|
||||
if (socket.readyState !== ws.OPEN) {
|
||||
//socket.isAlive = false
|
||||
} else {
|
||||
@ -106,7 +107,8 @@ module.exports = {
|
||||
my.wsServer.clients.forEach((socket) => {
|
||||
if (clid && socket.skid === clid) {
|
||||
delete socket.usid
|
||||
// 要不要清除 socket.? 似乎不清除也没问题
|
||||
delete socket.commid
|
||||
// 要不要清除 socket.?clid 似乎不清除也没问题
|
||||
}
|
||||
})
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user