fix(#30): Ensure kicking a user always works

This commit is contained in:
Josh Creek
2024-04-04 12:10:07 +01:00
parent 64d8c56a68
commit ec7b111699
2 changed files with 12 additions and 1 deletions
+8 -1
View File
@@ -1,6 +1,13 @@
<script lang="ts">
const changesLog = [
{ timestamp: '2024-02-11T19:00:00', message: 'Added celebration when all users have the same estimate (cred: O. Nicholass)' },
{
timestamp: '2024-02-11T19:00:00',
message: 'Added fix to ensure that kicking a user always works'
},
{
timestamp: '2024-02-11T19:00:00',
message: 'Added celebration when all users have the same estimate (cred: O. Nicholass)'
},
{ timestamp: '2024-01-05T00:00:00', message: 'Added the ability to kick a user' },
{ timestamp: '2024-01-05T00:00:00', message: 'Added update notes' }
];
+4
View File
@@ -171,12 +171,16 @@ wss.on('connection', (ws: WebSocket, req) => {
console.log('kick user message received');
if (room) {
const userIdToKick = data.userId;
const ws = room.getWebSocketByUserId(userIdToKick);
console.log(userIdToKick, ws);
if (ws) {
console.log('closing ws');
ws.close();
}
// Remove them from the room even if the active websocket can't be found or can't be closed
room.removeUser(userIdToKick);
}
}
});