chore(.gitignore) ignore vscode settings

refactor(websockets) remove systemMessage, add TotalMembers broadcast
This commit is contained in:
2023-09-06 11:32:06 -04:00
parent 7ac8eb29c3
commit 7035f4a689
2 changed files with 5 additions and 16 deletions

1
.gitignore vendored
View File

@@ -5,3 +5,4 @@ dist/
.env
thunder-tests/
coverage/
.vscode/settings.json

View File

@@ -1,6 +1,6 @@
import { MessageI, RoomI } from 'discreetly-interfaces';
import { Socket, Server as SocketIOServer } from 'socket.io';
import { findRoomById, createSystemMessages } from '../data/db/';
import { findRoomById } from '../data/db/';
import { pp } from '../utils';
import { validateMessage } from '../data/messages';
import type { validateMessageResult } from '../data/messages';
@@ -46,20 +46,8 @@ export function websocketSetup(io: SocketIOServer) {
io.to(roomID).emit('Members', userCount[roomID] ? userCount[roomID] : 0);
});
// TODO We need to rewrite this so it doesn't use `socket.on`, because this allows anyone to be able to broadcast a system message to any room.
// socket.on('systemMessage', (msg: string, roomID: bigint) => {
// const id = roomID.toString();
// createSystemMessages(msg, id)
// .then(() => {
// if (roomID) {
// io.to(id).emit('systemMessage', msg);
// } else {
// io.emit('systemMessage', msg);
// }
// })
// .catch((err) => {
// pp(err, 'error');
// });
// });
setInterval(() => {
io.emit('TotalMembers', io.engine.clientsCount);
}, 10000);
});
}