@node-red/runtime 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/multiplayer/index.js +31 -27
- package/package.json +3 -3
package/lib/multiplayer/index.js
CHANGED
|
@@ -23,14 +23,16 @@ module.exports = {
|
|
|
23
23
|
if (existingSessionId) {
|
|
24
24
|
connections.delete(opts.session)
|
|
25
25
|
const session = sessions.get(existingSessionId)
|
|
26
|
-
session
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
if (session) {
|
|
27
|
+
session.active = false
|
|
28
|
+
session.idleTimeout = setTimeout(() => {
|
|
29
|
+
sessions.delete(existingSessionId)
|
|
30
|
+
}, 30000)
|
|
31
|
+
runtime.events.emit('comms', {
|
|
32
|
+
topic: "multiplayer/connection-removed",
|
|
33
|
+
data: { session: existingSessionId }
|
|
34
|
+
})
|
|
35
|
+
}
|
|
34
36
|
}
|
|
35
37
|
})
|
|
36
38
|
runtime.events.on('comms:message:multiplayer/connect', (opts) => {
|
|
@@ -91,29 +93,31 @@ module.exports = {
|
|
|
91
93
|
const sessionId = connections.get(opts.session)
|
|
92
94
|
const session = sessions.get(sessionId)
|
|
93
95
|
|
|
94
|
-
if (
|
|
95
|
-
if (
|
|
96
|
-
session.user
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
if (session) {
|
|
97
|
+
if (opts.user) {
|
|
98
|
+
if (session.user.anonymous !== opts.user.anonymous) {
|
|
99
|
+
session.user = opts.user
|
|
100
|
+
runtime.events.emit('comms', {
|
|
101
|
+
topic: 'multiplayer/connection-added',
|
|
102
|
+
excludeSession: opts.session,
|
|
103
|
+
data: session
|
|
104
|
+
})
|
|
105
|
+
}
|
|
102
106
|
}
|
|
103
|
-
}
|
|
104
107
|
|
|
105
|
-
|
|
108
|
+
session.location = opts.data
|
|
106
109
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
const payload = {
|
|
111
|
+
session: sessionId,
|
|
112
|
+
workspace: opts.data.workspace,
|
|
113
|
+
node: opts.data.node
|
|
114
|
+
}
|
|
115
|
+
runtime.events.emit('comms', {
|
|
116
|
+
topic: 'multiplayer/location',
|
|
117
|
+
data: payload,
|
|
118
|
+
excludeSession: opts.session
|
|
119
|
+
})
|
|
111
120
|
}
|
|
112
|
-
runtime.events.emit('comms', {
|
|
113
|
-
topic: 'multiplayer/location',
|
|
114
|
-
data: payload,
|
|
115
|
-
excludeSession: opts.session
|
|
116
|
-
})
|
|
117
121
|
})
|
|
118
122
|
}
|
|
119
123
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-red/runtime",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@node-red/registry": "4.0.
|
|
20
|
-
"@node-red/util": "4.0.
|
|
19
|
+
"@node-red/registry": "4.0.2",
|
|
20
|
+
"@node-red/util": "4.0.2",
|
|
21
21
|
"async-mutex": "0.5.0",
|
|
22
22
|
"clone": "2.1.2",
|
|
23
23
|
"express": "4.19.2",
|