aotrautils-srv 0.0.322 → 0.0.324

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.
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- /*utils COMMONS library associated with aotra version : «1_29072022-2359 (04/12/2022-02:34:21)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (04/12/2022-13:37:57)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -4827,7 +4827,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4827
4827
 
4828
4828
 
4829
4829
 
4830
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (04/12/2022-02:34:21)»*/
4830
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (04/12/2022-13:37:57)»*/
4831
4831
  /*-----------------------------------------------------------------------------*/
4832
4832
 
4833
4833
 
@@ -5184,18 +5184,19 @@ WebsocketImplementation={
5184
5184
  clientPingIntervalMillis:5000,
5185
5185
  // clientsSockets:[],
5186
5186
  serverSocket:serverSocket,
5187
- receptionEntryPoints:[],
5187
+ receptionEntryPointsByClient:{},
5188
5188
 
5189
- receive:(channelName, doOnIncomingMessage, clientsRoomsTag=null)=>{
5189
+ receive:(channelNameParam, doOnIncomingMessage, clientsRoomsTag=null)=>{
5190
5190
 
5191
5191
  // DBG
5192
- lognow("(SERVER) Registering receive for «"+channelName+"»...",doOnIncomingMessage);
5192
+ lognow("(SERVER) Registering receive for «"+channelNameParam+"»...",doOnIncomingMessage);
5193
+
5193
5194
 
5194
5195
 
5195
5196
  const receptionEntryPoint={
5196
- channelName:channelName,
5197
+ channelName:channelNameParam,
5197
5198
  clientsRoomsTag:clientsRoomsTag,
5198
- execute:(eventOrMessage, clientSocketParam)=>{
5199
+ execute:(eventOrMessage, clientSocketParam, clientId)=>{
5199
5200
 
5200
5201
  // With «ws» library we have no choive than register message events inside a «connection» event !
5201
5202
 
@@ -5219,7 +5220,7 @@ WebsocketImplementation={
5219
5220
 
5220
5221
 
5221
5222
  // DBG
5222
- lognow("(SERVER) ENTRY POINT IS OF THE RIGHT CHANNEL:", channelName);
5223
+ lognow("(SERVER) ENTRY POINT IS OF THE RIGHT CHANNEL:", receptionEntryPoint.channelName);
5223
5224
 
5224
5225
 
5225
5226
 
@@ -5241,12 +5242,11 @@ WebsocketImplementation={
5241
5242
  };
5242
5243
 
5243
5244
 
5244
- nodeServerInstance.receptionEntryPoints.push(receptionEntryPoint);
5245
+ if(!nodeServerInstance.receptionEntryPointsByClient[clientId])
5246
+ nodeServerInstance.receptionEntryPointsByClient[clientId]=[];
5247
+ nodeServerInstance.receptionEntryPointsByClient[clientId].push(receptionEntryPoint);
5245
5248
 
5246
5249
 
5247
- // // DBG
5248
- // console.log("ADD RECEPTION ENTRY POINT channelName:«"+channelName+"»! nodeServerInstance.receptionEntryPoints.length:",nodeServerInstance.receptionEntryPoints.length);
5249
-
5250
5250
 
5251
5251
  return nodeServerInstance;
5252
5252
  },
@@ -5343,20 +5343,18 @@ WebsocketImplementation={
5343
5343
  // if(contains(nodeServerInstance.clientsSockets, clientSocket)) return;
5344
5344
  // nodeServerInstance.clientsSockets.push(clientSocket);
5345
5345
 
5346
-
5347
- // DBG
5348
- clientSocket.clientId=getUUID();
5346
+ const clientId=getUUID();
5347
+ clientSocket.clientId=clientId;
5349
5348
 
5350
5349
 
5351
- // // DBG
5352
- // console.log("nodeServerInstance.receptionEntryPoints.length:",nodeServerInstance.receptionEntryPoints.length);
5353
-
5354
5350
 
5355
5351
  const doOnMessage=(eventOrMessage)=>{
5356
5352
 
5357
5353
  // We execute the events registration listeners entry points:
5358
- foreach(nodeServerInstance.receptionEntryPoints,(receptionEntryPoint,i)=>{
5359
- receptionEntryPoint.execute(eventOrMessage, clientSocket);
5354
+ if(!nodeServerInstance.receptionEntryPointsByClient[clientId])
5355
+ return;
5356
+ foreach(nodeServerInstance.receptionEntryPointsByClient[clientId],(receptionEntryPoint,i)=>{
5357
+ receptionEntryPoint.execute(eventOrMessage, clientSocket, clientId);
5360
5358
  });
5361
5359
 
5362
5360
  };
@@ -5381,7 +5379,10 @@ WebsocketImplementation={
5381
5379
 
5382
5380
 
5383
5381
  // On today, this method is named as same for the two implementations :
5382
+ // TRACE
5383
+ lognow("(SERVER) Removing all listeners and receptjion entrypoints for client socket «"+clientSocket.clientId+"».");
5384
5384
  clientSocket.removeAllListeners();
5385
+ nodeServerInstance.receptionEntryPointsByClient[clientSocket.clientId]=[];
5385
5386
 
5386
5387
 
5387
5388
  // TODO : FIXME : Use one single interface !
@@ -5540,10 +5541,10 @@ WebsocketImplementation={
5540
5541
 
5541
5542
  receptionEntryPoints:[],
5542
5543
 
5543
- receive:(channelName, doOnIncomingMessage, clientsRoomsTag=null)=>{
5544
+ receive:(channelNameParam, doOnIncomingMessage, clientsRoomsTag=null)=>{
5544
5545
 
5545
5546
  const receptionEntryPoint={
5546
- channelName:channelName,
5547
+ channelName:channelNameParam,
5547
5548
  clientsRoomsTag:clientsRoomsTag,
5548
5549
  execute:(eventOrMessage)=>{
5549
5550
 
@@ -5554,7 +5555,7 @@ WebsocketImplementation={
5554
5555
  const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
5555
5556
 
5556
5557
  // Channel information is stored in exchanged data :
5557
- if(dataWrapped.channelName && dataWrapped.channelName!==channelName) return;
5558
+ if(dataWrapped.channelName && dataWrapped.channelName!==channelNameParam) return;
5558
5559
 
5559
5560
  const clientSocket=nodeClientInstance.clientSocket;
5560
5561
 
@@ -5574,7 +5575,7 @@ WebsocketImplementation={
5574
5575
  },
5575
5576
 
5576
5577
 
5577
- send:(channelName, data, clientsRoomsTag=null)=>{
5578
+ send:(channelNameParam, data, clientsRoomsTag=null)=>{
5578
5579
 
5579
5580
  const clientSocket=nodeClientInstance.clientSocket;
5580
5581
 
@@ -5591,7 +5592,7 @@ WebsocketImplementation={
5591
5592
  if(!WebsocketImplementation.isInRoom(clientSocket,clientsRoomsTag)) return;
5592
5593
 
5593
5594
  // Channel information is stored in exchanged data :
5594
- let dataWrapped={channelName:channelName, data:data};
5595
+ let dataWrapped={channelName:channelNameParam, data:data};
5595
5596
 
5596
5597
 
5597
5598
  // // DBG
@@ -5602,12 +5603,12 @@ WebsocketImplementation={
5602
5603
 
5603
5604
 
5604
5605
  // // DBG
5605
- // console.log("(NODE CLIENT) SENDING DATA ! channelName:«"+channelName+"» ; clientsRoomsTag:«"+clientsRoomsTag+"»");
5606
+ // console.log("(NODE CLIENT) SENDING DATA ! channelNameParam:«"+channelNameParam+"» ; clientsRoomsTag:«"+clientsRoomsTag+"»");
5606
5607
  // console.log("(NODE CLIENT) SENDING DATA ! dataWrapped:",dataWrapped);
5607
5608
 
5608
5609
  // TODO : FIXME : Use one single interface !
5609
5610
  if(!WebsocketImplementation.useSocketIOImplementation) clientSocket.send(dataWrapped);
5610
- else clientSocket.emit(channelName,dataWrapped);
5611
+ else clientSocket.emit(channelNameParam,dataWrapped);
5611
5612
 
5612
5613
  return nodeClientInstance;
5613
5614
  },
@@ -5645,7 +5646,7 @@ WebsocketImplementation={
5645
5646
 
5646
5647
  const clientSocket=nodeClientInstance.clientSocket;
5647
5648
  if(!WebsocketImplementation.useSocketIOImplementation) clientSocket.addEventListener("message", doOnMessage);
5648
- else clientSocket.on(channelName, doOnMessage);
5649
+ else clientSocket.on(channelNameParam, doOnMessage);
5649
5650
 
5650
5651
  doOnConnection(nodeClientInstance, clientSocket);
5651
5652
 
@@ -5711,10 +5712,10 @@ WebsocketImplementation={
5711
5712
  const browserInstance={
5712
5713
  clientSocket:clientSocket,
5713
5714
 
5714
- receive:(channelName, doOnIncomingMessage, clientsRoomsTag=null)=>{
5715
+ receive:(channelNameParam, doOnIncomingMessage, clientsRoomsTag=null)=>{
5715
5716
 
5716
5717
  // DBG
5717
- lognow("INFO : (CLIENT-BROWSER) SETTING UP RECEIVE for :",channelName);
5718
+ lognow("INFO : (CLIENT-BROWSER) SETTING UP RECEIVE for :",channelNameParam);
5718
5719
 
5719
5720
 
5720
5721
  const doOnMessage=(eventOrMessage)=>{
@@ -5726,7 +5727,7 @@ WebsocketImplementation={
5726
5727
 
5727
5728
 
5728
5729
  // Channel information is stored in exchanged data :
5729
- if(dataWrapped.channelName && dataWrapped.channelName!==channelName) return;
5730
+ if(dataWrapped.channelName && dataWrapped.channelName!==channelNameParam) return;
5730
5731
 
5731
5732
  const clientSocket=browserInstance.clientSocket;
5732
5733
 
@@ -5739,14 +5740,14 @@ WebsocketImplementation={
5739
5740
 
5740
5741
 
5741
5742
  if(!WebsocketImplementation.useSocketIOImplementation) browserInstance.clientSocket.addEventListener("message", doOnMessage);
5742
- else browserInstance.clientSocket.on(channelName, doOnMessage);
5743
+ else browserInstance.clientSocket.on(channelNameParam, doOnMessage);
5743
5744
 
5744
5745
 
5745
5746
  return browserInstance;
5746
5747
  },
5747
5748
 
5748
5749
 
5749
- send:(channelName, data, clientsRoomsTag=null)=>{
5750
+ send:(channelNameParam, data, clientsRoomsTag=null)=>{
5750
5751
 
5751
5752
  const clientSocket=browserInstance.clientSocket;
5752
5753
 
@@ -5763,7 +5764,7 @@ WebsocketImplementation={
5763
5764
  if(!WebsocketImplementation.isInRoom(clientSocket,clientsRoomsTag)) return;
5764
5765
 
5765
5766
  // Channel information is stored in exchanged data :
5766
- let dataWrapped={channelName:channelName, data:data};
5767
+ let dataWrapped={channelName:channelNameParam, data:data};
5767
5768
 
5768
5769
 
5769
5770
  // DBG
@@ -5776,7 +5777,7 @@ WebsocketImplementation={
5776
5777
 
5777
5778
  // TODO : FIXME : Use one single interface !
5778
5779
  if(!WebsocketImplementation.useSocketIOImplementation) clientSocket.send(dataWrapped);
5779
- else clientSocket.emit(channelName,dataWrapped);
5780
+ else clientSocket.emit(channelNameParam,dataWrapped);
5780
5781
 
5781
5782
 
5782
5783
  return browserInstance;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.322",
3
+ "version": "0.0.324",
4
4
  "main": "aotrautils-srv.build.js",
5
5
  "description": "A library for vanilla javascript utils (server-side) used in aotra javascript CMS",
6
6
  "author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",