adding boilerplate for database validations
This commit is contained in:
@@ -24,6 +24,12 @@ const usersCollection: mongoDB.Collection = db.collection('users');
|
|||||||
const lineCollection: mongoDB.Collection = db.collection('lines');
|
const lineCollection: mongoDB.Collection = db.collection('lines');
|
||||||
const lineMembersCollection: mongoDB.Collection = db.collection('lineMembers');
|
const lineMembersCollection: mongoDB.Collection = db.collection('lineMembers');
|
||||||
|
|
||||||
|
// client.on('connection', () => {
|
||||||
|
// db.command({
|
||||||
|
// collMod: 'lines',
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
collections.users = usersCollection;
|
collections.users = usersCollection;
|
||||||
collections.lines = lineCollection;
|
collections.lines = lineCollection;
|
||||||
collections.lineMembers = lineMembersCollection;
|
collections.lineMembers = lineMembersCollection;
|
||||||
|
|||||||
@@ -79,11 +79,12 @@ export default function InitializeWs(io: any) {
|
|||||||
/** CONNECT | User wants to subscribe to live emissions of a line */
|
/** CONNECT | User wants to subscribe to live emissions of a line */
|
||||||
socket.on(ServerRequestChannels.CONNECT_TO_LINE, (req: ConnectToLineRequest) => {
|
socket.on(ServerRequestChannels.CONNECT_TO_LINE, (req: ConnectToLineRequest) => {
|
||||||
// add this user to the room
|
// add this user to the room
|
||||||
console.log(`${socket.id} user CONNECTED room for line ${Object.keys(socket.rooms)}`);
|
|
||||||
|
|
||||||
const roomName = `connectedLine:${req.lineId}`;
|
const roomName = `connectedLine:${req.lineId}`;
|
||||||
socket.join(roomName);
|
socket.join(roomName);
|
||||||
|
|
||||||
|
console.log(`${socket.id} user CONNECTED room for line ${Object.keys(socket.rooms)}`);
|
||||||
|
|
||||||
const clientUserIdsInRoom = [...(io.sockets.adapter.rooms.get(roomName) ?? [])].map(
|
const clientUserIdsInRoom = [...(io.sockets.adapter.rooms.get(roomName) ?? [])].map(
|
||||||
(otherUserSocketId: string) => socketIdsToUserIds[otherUserSocketId],
|
(otherUserSocketId: string) => socketIdsToUserIds[otherUserSocketId],
|
||||||
);
|
);
|
||||||
@@ -96,11 +97,11 @@ export default function InitializeWs(io: any) {
|
|||||||
|
|
||||||
/** TUNE | User tunes into the line either temporarily or toggled in */
|
/** TUNE | User tunes into the line either temporarily or toggled in */
|
||||||
socket.on(ServerRequestChannels.TUNE_INTO_LINE, async (req: TuneToLineRequest) => {
|
socket.on(ServerRequestChannels.TUNE_INTO_LINE, async (req: TuneToLineRequest) => {
|
||||||
console.log(`${socket.id} user TUNED into room for line ${req.lineId}`);
|
|
||||||
|
|
||||||
const roomName = `tunedLine:${req.lineId}`;
|
const roomName = `tunedLine:${req.lineId}`;
|
||||||
socket.join(roomName);
|
socket.join(roomName);
|
||||||
|
|
||||||
|
console.log(`${socket.id} user TUNED into room for line ${req.lineId}`);
|
||||||
|
|
||||||
const clientUserIdsInRoom = [...(io.sockets.adapter.rooms.get(roomName) ?? [])].map(
|
const clientUserIdsInRoom = [...(io.sockets.adapter.rooms.get(roomName) ?? [])].map(
|
||||||
(otherUserSocketId: string) => socketIdsToUserIds[otherUserSocketId],
|
(otherUserSocketId: string) => socketIdsToUserIds[otherUserSocketId],
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user