getting data transformation with pub sub, although just need to solidify with more flow and just do it step by step as it can get complex

This commit is contained in:
talksik
2022-05-06 10:41:28 -05:00
parent 61c2ac14af
commit f3cd9edc95
5 changed files with 99 additions and 10 deletions
+15
View File
@@ -3,6 +3,8 @@ import SocketChannels, {
SomeoneConnected,
SomeoneTuned,
TuneToLine,
UserBroadcastPull,
UserBroadcastingPush,
} from "@nirvana/core/sockets/channels";
import GetAllSocketClients from "@nirvana/core/sockets/getAllActiveSocketClients";
@@ -95,6 +97,19 @@ export default function InitializeWs(io: any) {
);
});
/** BROADCAST UPDATE | tell all who are connected to line, not just tuned into, that there is an update to someone broadcasting */
socket.on(
SocketChannels.USER_BROADCAST_PUSH_PULL,
(req: UserBroadcastingPush) => {
const roomName = `connectedLine:${req.lineId}`;
io.in(roomName).emit(
SocketChannels.USER_BROADCAST_PUSH_PULL,
new UserBroadcastPull(req.lineId, userInfo.userId, req.isTurningOn)
);
}
);
socket.on(SocketChannels.JOIN_LIVE_ROOM, async () => {
// TODO: only get the socket ids of the relevant rooms for this user
// return all Socket instances