+ });
+
+ socket.on(events.types.DISCONNECTING, () => {
+ for (const room in rooms) {
+ if (rooms[room].includes(me)) {
+ rooms[room] = rooms[room].filter((id) => id !== me);
+ events.removePeer(me)(socket.to(room));
+ if (rooms[room].length === 0) {
+ delete rooms[room];
+ }
+ }
+ }
+ });
+
+ socket.on(events.types.RELAY_ICE_CANDIDATE, async ({ candidate, peerId }) => {
+ events.ICECandidateReceived(me, candidate)(socket.to(peerId));
+ });
+
+ socket.on(events.types.RELAY_OFFER, async ({ offer, peerId }) => {
+ events.offerReceived(me, offer)(socket.to(peerId));
+ });
+
+ socket.on(events.types.RELAY_ANSWER, async ({ answer, peerId }) => {
+ events.answerReceived(me, answer)(socket.to(peerId));
+ });