Merge pull request #4816 from node-red/4814-multiplayer-uncaught

Guard against undefined sessions in multiplayer
This commit is contained in:
Nick O'Leary 2024-06-28 16:58:25 +01:00 committed by GitHub
commit 93974ccd92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -23,6 +23,7 @@ module.exports = {
if (existingSessionId) {
connections.delete(opts.session)
const session = sessions.get(existingSessionId)
if (session) {
session.active = false
session.idleTimeout = setTimeout(() => {
sessions.delete(existingSessionId)
@ -32,6 +33,7 @@ module.exports = {
data: { session: existingSessionId }
})
}
}
})
runtime.events.on('comms:message:multiplayer/connect', (opts) => {
let session
@ -91,6 +93,7 @@ module.exports = {
const sessionId = connections.get(opts.session)
const session = sessions.get(sessionId)
if (session) {
if (opts.user) {
if (session.user.anonymous !== opts.user.anonymous) {
session.user = opts.user
@ -114,6 +117,7 @@ module.exports = {
data: payload,
excludeSession: opts.session
})
}
})
}
}