mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge pull request #4816 from node-red/4814-multiplayer-uncaught
Guard against undefined sessions in multiplayer
This commit is contained in:
commit
93974ccd92
@ -23,6 +23,7 @@ module.exports = {
|
|||||||
if (existingSessionId) {
|
if (existingSessionId) {
|
||||||
connections.delete(opts.session)
|
connections.delete(opts.session)
|
||||||
const session = sessions.get(existingSessionId)
|
const session = sessions.get(existingSessionId)
|
||||||
|
if (session) {
|
||||||
session.active = false
|
session.active = false
|
||||||
session.idleTimeout = setTimeout(() => {
|
session.idleTimeout = setTimeout(() => {
|
||||||
sessions.delete(existingSessionId)
|
sessions.delete(existingSessionId)
|
||||||
@ -32,6 +33,7 @@ module.exports = {
|
|||||||
data: { session: existingSessionId }
|
data: { session: existingSessionId }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
runtime.events.on('comms:message:multiplayer/connect', (opts) => {
|
runtime.events.on('comms:message:multiplayer/connect', (opts) => {
|
||||||
let session
|
let session
|
||||||
@ -91,6 +93,7 @@ module.exports = {
|
|||||||
const sessionId = connections.get(opts.session)
|
const sessionId = connections.get(opts.session)
|
||||||
const session = sessions.get(sessionId)
|
const session = sessions.get(sessionId)
|
||||||
|
|
||||||
|
if (session) {
|
||||||
if (opts.user) {
|
if (opts.user) {
|
||||||
if (session.user.anonymous !== opts.user.anonymous) {
|
if (session.user.anonymous !== opts.user.anonymous) {
|
||||||
session.user = opts.user
|
session.user = opts.user
|
||||||
@ -114,6 +117,7 @@ module.exports = {
|
|||||||
data: payload,
|
data: payload,
|
||||||
excludeSession: opts.session
|
excludeSession: opts.session
|
||||||
})
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user