cleaning up tuning and untuning keeping it simple

This commit is contained in:
talksik
2022-05-14 11:08:37 -05:00
parent 7c66a6a4f3
commit 723427b7cc
3 changed files with 32 additions and 14 deletions
+10 -2
View File
@@ -85,9 +85,13 @@ export default function InitializeWs(io: any) {
const roomName = `connectedLine:${req.lineId}`;
socket.join(roomName);
const clientUserIdsInRoom = [...(io.sockets.adapter.rooms.get(roomName) ?? [])].map(
(otherUserSocketId: string) => socketIdsToUserIds[otherUserSocketId],
);
io.in(roomName).emit(
ServerResponseChannels.SOMEONE_CONNECTED_TO_LINE,
new SomeoneConnectedResponse(req.lineId, userInfo.userId),
new SomeoneConnectedResponse(req.lineId, userInfo.userId, clientUserIdsInRoom),
);
});
@@ -98,12 +102,16 @@ export default function InitializeWs(io: any) {
const roomName = `tunedLine:${req.lineId}`;
socket.join(roomName);
const clientUserIdsInRoom = [...(io.sockets.adapter.rooms.get(roomName) ?? [])].map(
(otherUserSocketId: string) => socketIdsToUserIds[otherUserSocketId],
);
// we want to notify everyone connected to the line even if they are not tuned in
const connectedLineRoomName = `connectedLine:${req.lineId}`;
io.in(connectedLineRoomName).emit(
ServerResponseChannels.SOMEONE_TUNED_INTO_LINE,
new SomeoneTunedResponse(req.lineId, userInfo.userId),
new SomeoneTunedResponse(req.lineId, userInfo.userId, clientUserIdsInRoom),
);
});