rename user 'uuid' to 'usid'
This commit is contained in:
parent
ac76575e4f
commit
6c798bcd00
@ -30,8 +30,8 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
if (dataObj.skevent === 'SOCKET_OWNER') {
|
if (dataObj.skevent === 'SOCKET_OWNER') {
|
||||||
dataObj._passtokenSource = webtoken.verifyToken(dataObj._passtoken) // todo: 为防止前端欺骗,应当用和login里类似的方法来检查来检查
|
dataObj._passtokenSource = webtoken.verifyToken(dataObj._passtoken) // todo: 为防止前端欺骗,应当用和login里类似的方法来检查来检查
|
||||||
if (typeof dataObj._passtokenSource?.uuid === 'string') {
|
if (typeof dataObj._passtokenSource?.usid === 'string') {
|
||||||
my.socketPool[dataObj._passtokenSource.uuid] = socket
|
my.socketPool[dataObj._passtokenSource.usid] = socket
|
||||||
console.log('收到 Login 成功的消息,绑定socket', Object.keys(my.socketPool))
|
console.log('收到 Login 成功的消息,绑定socket', Object.keys(my.socketPool))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,8 +55,8 @@ module.exports = {
|
|||||||
return this
|
return this
|
||||||
},
|
},
|
||||||
|
|
||||||
removeUserSocket (uuid) {
|
removeUserSocket (usid) {
|
||||||
delete my.socketPool[uuid]
|
delete my.socketPool[usid]
|
||||||
},
|
},
|
||||||
|
|
||||||
addListener (skevent, listener) {
|
addListener (skevent, listener) {
|
||||||
@ -73,17 +73,17 @@ module.exports = {
|
|||||||
if (socket.readyState === socket.OPEN) {
|
if (socket.readyState === socket.OPEN) {
|
||||||
socket.send(typeof dataObj !== 'string' ? JSON.stringify(dataObj) : dataObj)
|
socket.send(typeof dataObj !== 'string' ? JSON.stringify(dataObj) : dataObj)
|
||||||
} else {
|
} else {
|
||||||
delete my.socketPool[socket.uuid]
|
delete my.socketPool[socket.usid]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
sendToOne (dataObj, uuid) {
|
sendToOne (dataObj, usid) {
|
||||||
const socket = my.socketPool[uuid]
|
const socket = my.socketPool[usid]
|
||||||
if (socket && socket.readyState === socket.OPEN) {
|
if (socket && socket.readyState === socket.OPEN) {
|
||||||
socket.send(typeof dataObj !== 'string' ? JSON.stringify(dataObj) : dataObj)
|
socket.send(typeof dataObj !== 'string' ? JSON.stringify(dataObj) : dataObj)
|
||||||
} else {
|
} else {
|
||||||
delete my.socketPool[uuid]
|
delete my.socketPool[usid]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user