@cocreate/socket-server 1.21.11 → 1.23.0
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/CHANGELOG.md +19 -0
- package/package.json +4 -4
- package/src/index.js +9 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [1.23.0](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.22.0...v1.23.0) (2023-11-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* userStatus across various clientid ([507d5e5](https://github.com/CoCreate-app/CoCreate-socket-server/commit/507d5e5b7e17a6aadb6b1b4522b8f753d0156715))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* upgrade dependencies for latest features and fixes ([5176e69](https://github.com/CoCreate-app/CoCreate-socket-server/commit/5176e69558a57af55d003608fb24515103877edd))
|
|
12
|
+
|
|
13
|
+
# [1.22.0](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.21.11...v1.22.0) (2023-11-19)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* update dependecies for th latest features and bug fixes ([6da29d2](https://github.com/CoCreate-app/CoCreate-socket-server/commit/6da29d232c85a774af066838141a8b399ae21ba1))
|
|
19
|
+
|
|
1
20
|
## [1.21.11](https://github.com/CoCreate-app/CoCreate-socket-server/compare/v1.21.10...v1.21.11) (2023-11-16)
|
|
2
21
|
|
|
3
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/socket-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0",
|
|
4
4
|
"description": "CoCreate-socket-server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cocreate-socket",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
},
|
|
41
41
|
"homepage": "https://cocreate.app/docs/CoCreate-socket-server",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@cocreate/config": "^1.
|
|
44
|
-
"@cocreate/uuid": "^1.
|
|
45
|
-
"@cocreate/utils": "^1.
|
|
43
|
+
"@cocreate/config": "^1.7.0",
|
|
44
|
+
"@cocreate/uuid": "^1.8.0",
|
|
45
|
+
"@cocreate/utils": "^1.28.0",
|
|
46
46
|
"ws": "7.5.9"
|
|
47
47
|
}
|
|
48
48
|
}
|
package/src/index.js
CHANGED
|
@@ -88,7 +88,7 @@ class SocketServer extends EventEmitter {
|
|
|
88
88
|
|
|
89
89
|
if (self.authenticate) {
|
|
90
90
|
const { user_id, expires } = self.authenticate.decodeToken(options.token)
|
|
91
|
-
const userStatus = { socket, method: 'userStatus', user_id: options.user_id, userStatus: 'off', organization_id }
|
|
91
|
+
const userStatus = { socket, method: 'userStatus', user_id: options.user_id, clientId: options.clientId, userStatus: 'off', organization_id }
|
|
92
92
|
if (user_id) {
|
|
93
93
|
options.user_id = user_id
|
|
94
94
|
socket.user_id = user_id;
|
|
@@ -181,7 +181,7 @@ class SocketServer extends EventEmitter {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
if (socket.user_id) {
|
|
184
|
-
this.emit('userStatus', { socket, user_id: socket.user_id, userStatus: 'on', organization_id });
|
|
184
|
+
this.emit('userStatus', { socket, user_id: socket.user_id, clientId: socket.clientId, userStatus: 'on', organization_id });
|
|
185
185
|
let user = this.users.get(socket.user_id)
|
|
186
186
|
|
|
187
187
|
if (!Array.isArray(user)) {
|
|
@@ -298,7 +298,7 @@ class SocketServer extends EventEmitter {
|
|
|
298
298
|
clearTimeout(userDebounceTimer);
|
|
299
299
|
userDebounceTimer = setTimeout(() => {
|
|
300
300
|
this.users.delete(socket.user_id);
|
|
301
|
-
this.emit('userStatus', { socket, user_id: socket.user_id, userStatus: 'off', organization_id });
|
|
301
|
+
this.emit('userStatus', { socket, user_id: socket.user_id, clientId: socket.clientId, userStatus: 'off', organization_id });
|
|
302
302
|
}, 10000);
|
|
303
303
|
|
|
304
304
|
this.users.set(socket.user_id, userDebounceTimer)
|
|
@@ -333,8 +333,13 @@ class SocketServer extends EventEmitter {
|
|
|
333
333
|
console.log('data.method: ', data.method)
|
|
334
334
|
|
|
335
335
|
if (socket.user_id && socket.expires && new Date(new Date().toISOString()).getTime() >= socket.expires) {
|
|
336
|
+
// data.error = 'Token expired'
|
|
337
|
+
// socket.send(JSON.stringify(data))
|
|
338
|
+
await this.send({
|
|
339
|
+
socket, method: 'updateUserStatus', user_id: socket.user_id, clientId: data.clientId, userStatus: 'off', socketId: data.socketId, organization_id
|
|
340
|
+
})
|
|
336
341
|
socket.user_id = socket.expires = null
|
|
337
|
-
|
|
342
|
+
return
|
|
338
343
|
}
|
|
339
344
|
|
|
340
345
|
if (this.authorize) {
|