Skip to content

Commit 4f9ba84

Browse files
committed
fix: reduce message userStatus
1 parent f8cfcbf commit 4f9ba84

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class SocketServer extends EventEmitter{
6464

6565
addClient(socket) {
6666
let organization_id = socket.config.organization_id
67+
let user_id = socket.config.user_id
6768
let key = socket.config.key
6869
let room_clients = this.clients.get(key);
6970
if (room_clients) {
@@ -78,7 +79,10 @@ class SocketServer extends EventEmitter{
7879
if (!asyncMessage) {
7980
this.asyncMessages.set(key, new AsyncMessage(key));
8081
}
81-
82+
83+
if (user_id)
84+
this.emit('userStatus', socket, {user_id, userStatus: 'on', organization_id});
85+
8286
//. add metrics
8387
let total_cnt = 0;
8488
this.clients.forEach((c) => total_cnt += c.length)
@@ -157,8 +161,8 @@ class SocketServer extends EventEmitter{
157161
if (user_id) {
158162
if (!socket.config.user_id ) {
159163
socket.config.user_id = user_id
164+
this.emit('userStatus', socket, {user_id, userStatus: 'on', organization_id});
160165
}
161-
this.emit('userStatus', socket, {user_id, userStatus: 'on', organization_id});
162166
}
163167

164168
//. checking async status....

0 commit comments

Comments
 (0)