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') {
|
if (typeof _passtokenSource?.usid === 'string') {
|
||||||
socket.appkey = _passtokenSource.appkey
|
socket.appkey = _passtokenSource.appkey
|
||||||
socket.usid = _passtokenSource.usid
|
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
|
// my.socketPool[socket.skid] = socket
|
||||||
console.log(
|
console.log(
|
||||||
{
|
{
|
||||||
@ -88,7 +89,7 @@ module.exports = {
|
|||||||
console.log('WebSocket_heartbeat: starting...')
|
console.log('WebSocket_heartbeat: starting...')
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
my.wsServer.clients.forEach((socket) => {
|
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) {
|
if (socket.readyState !== ws.OPEN) {
|
||||||
//socket.isAlive = false
|
//socket.isAlive = false
|
||||||
} else {
|
} else {
|
||||||
@ -106,7 +107,8 @@ module.exports = {
|
|||||||
my.wsServer.clients.forEach((socket) => {
|
my.wsServer.clients.forEach((socket) => {
|
||||||
if (clid && socket.skid === clid) {
|
if (clid && socket.skid === clid) {
|
||||||
delete socket.usid
|
delete socket.usid
|
||||||
// 要不要清除 socket.? 似乎不清除也没问题
|
delete socket.commid
|
||||||
|
// 要不要清除 socket.?clid 似乎不清除也没问题
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user