@ejfdelgado/ejflab-back 1.32.1 → 1.32.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ejfdelgado/ejflab-back",
3
- "version": "1.32.1",
3
+ "version": "1.32.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ejfdelgado/ejflab-back.git"
@@ -48,6 +48,7 @@ export class SocketIOCall {
48
48
  static socketIdToSocket = {};
49
49
  static socketRoomUUIDMap = {};
50
50
  static socketToImage = {};
51
+ static hookProcessors = {};
51
52
 
52
53
  static echoLog(message) {
53
54
  console.log(message);
@@ -139,7 +140,7 @@ export class SocketIOCall {
139
140
  }
140
141
 
141
142
  static async registerSocket(socket) {
142
- console.log("registerSocket...");
143
+ console.log("registerSocket...!");
143
144
  SocketIOCall.socketIdToSocket[socket.id] = socket;
144
145
  const headers = SocketIOCall.getCustomHeaders(socket);
145
146
  const room = headers.room;
@@ -162,6 +163,7 @@ export class SocketIOCall {
162
163
  if (typeof myUUID == "string" && myUUID !== "null") {
163
164
  SocketIOCall.socketRoomUUIDMap[room][myUUID] = socket.id;
164
165
  }
166
+ // Here creates the uuid mapping
165
167
  console.log(JSON.stringify(SocketIOCall.socketRoomUUIDMap, null, 4));
166
168
  release();
167
169
  console.log(`${socket.id} joins ${headers.room}`);
@@ -369,8 +371,22 @@ export class SocketIOCall {
369
371
  //SocketIOCall.echoLog(`${socket.id} sends includeOtherPeers with ${JSON.stringify(payload)}`);
370
372
  new IncludeOtherPeersProcessor(SocketIOCall, SocketIOCall.io, socket).executeSave(payload);
371
373
  });
374
+
375
+ const extraHooks = Object.keys(SocketIOCall.hookProcessors);
376
+ for (let k = 0; k < extraHooks.length; k++) {
377
+ const hookId = extraHooks[k];
378
+ socket.on(hookId, (payload) => {
379
+ const className = SocketIOCall.hookProcessors[hookId];
380
+ new className(SocketIOCall, SocketIOCall.io, socket).executeSave(payload);
381
+ });
382
+ }
372
383
  }
373
384
 
385
+ static registerHookProcessors(map) {
386
+ this.hookProcessors = map;
387
+ }
388
+
389
+ // SocketIOCall.disconnect
374
390
  static async disconnect(socket) {
375
391
  const headers = SocketIOCall.getCustomHeaders(socket);
376
392
  //socket.off();
@@ -379,6 +395,10 @@ export class SocketIOCall {
379
395
  SocketIOCall.io.to(headers.room).emit("removeUser", {
380
396
  socketId: socket.id
381
397
  });
398
+ const room = headers.room;
399
+ SocketIOCall.io.to(room).emit("updateUserList", {
400
+ socketIds: SocketIOCall.mapSockets[room]
401
+ });
382
402
  }
383
403
 
384
404
  static handle(io) {