Skip to content
This repository was archived by the owner on Dec 15, 2019. It is now read-only.

Commit faea35c

Browse files
committed
Prefix socket messages with type
1 parent a5ae600 commit faea35c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/websocket.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ module.exports = server => {
3535
userMap[userid].push(ws);
3636

3737
// Approve registration
38-
ws.send('registration-approval');
38+
ws.send(JSON.stringify({
39+
type: 'registration-approval',
40+
value: {
41+
connections: userMap[userid].length
42+
}
43+
}));
3944
}
4045

4146
break;
@@ -49,7 +54,10 @@ module.exports = server => {
4954
const socket = socketList[i];
5055

5156
if (socket !== ws) {
52-
socket.send(JSON.stringify(value));
57+
socket.send(JSON.stringify({
58+
type: 'broadcast',
59+
value
60+
}));
5361
}
5462
}
5563
}

0 commit comments

Comments
 (0)