Skip to content

Commit

Permalink
fix: reduce message userStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Dec 21, 2022
1 parent f8cfcbf commit 4f9ba84
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class SocketServer extends EventEmitter{

addClient(socket) {
let organization_id = socket.config.organization_id
let user_id = socket.config.user_id
let key = socket.config.key
let room_clients = this.clients.get(key);
if (room_clients) {
Expand All @@ -78,7 +79,10 @@ class SocketServer extends EventEmitter{
if (!asyncMessage) {
this.asyncMessages.set(key, new AsyncMessage(key));
}


if (user_id)
this.emit('userStatus', socket, {user_id, userStatus: 'on', organization_id});

//. add metrics
let total_cnt = 0;
this.clients.forEach((c) => total_cnt += c.length)
Expand Down Expand Up @@ -157,8 +161,8 @@ class SocketServer extends EventEmitter{
if (user_id) {
if (!socket.config.user_id ) {
socket.config.user_id = user_id
this.emit('userStatus', socket, {user_id, userStatus: 'on', organization_id});
}
this.emit('userStatus', socket, {user_id, userStatus: 'on', organization_id});
}

//. checking async status....
Expand Down

0 comments on commit 4f9ba84

Please sign in to comment.