aotrautils-srv 0.0.298 → 0.0.300

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 (27/11/2022-22:57:04)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (01/12/2022-00:01:29)»*/
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 (27/11/2022-22:57:04)»*/
4830
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (01/12/2022-00:01:29)»*/
4831
4831
  /*-----------------------------------------------------------------------------*/
4832
4832
 
4833
4833
 
@@ -5198,13 +5198,9 @@ WebsocketImplementation={
5198
5198
  const receptionEntryPoint={
5199
5199
  channelName:channelName,
5200
5200
  clientsRoomsTag:clientsRoomsTag,
5201
- execute:(clientSocketParam, eventOrMessage)=>{
5201
+ execute:(eventOrMessage, clientSocketParam)=>{
5202
5202
 
5203
-
5204
5203
  // With «ws» library we have no choive than register message events inside a «connection» event !
5205
- // nodeServerInstance.onConnectionToClient((serverParam, clientSocketParam)=>{
5206
-
5207
-
5208
5204
 
5209
5205
  // DBG
5210
5206
  lognow("(SERVER) RECEIVED SOMETHING FROM CLIENT...", eventOrMessage.data);
@@ -5349,49 +5345,25 @@ WebsocketImplementation={
5349
5345
  clientSocket.clientId=getUUID();
5350
5346
 
5351
5347
 
5352
- // // DBG
5353
- // console.log("nodeServerInstance.receptionEntryPoints.length:",nodeServerInstance.receptionEntryPoints.length);
5354
-
5355
-
5348
+ // // DBG
5349
+ // console.log("nodeServerInstance.receptionEntryPoints.length:",nodeServerInstance.receptionEntryPoints.length);
5356
5350
 
5357
5351
 
5358
- ////
5352
+ const doOnMessage=(eventOrMessage)=>{
5359
5353
 
5360
- doOnMessage=(eventOrMessage)=>{
5361
-
5362
-
5363
5354
  // We execute the events registration listeners entry points:
5364
5355
  foreach(nodeServerInstance.receptionEntryPoints,(receptionEntryPoint,i)=>{
5365
-
5366
- // DBG
5367
- console.log("(SERVER) ENTRY POINT ["+i+"] is executed !");
5368
-
5369
- receptionEntryPoint.execute(clientSocket, eventOrMessage);
5356
+ receptionEntryPoint.execute(eventOrMessage, clientSocket);
5370
5357
  });
5371
5358
 
5372
5359
  };
5373
5360
 
5374
-
5375
5361
  if(!WebsocketImplementation.useSocketIOImplementation) clientSocket.addEventListener("message", doOnMessage);
5376
5362
  else clientSocket.on(channelName, doOnMessage);
5377
5363
 
5378
-
5379
-
5380
-
5381
-
5382
-
5383
-
5384
-
5385
-
5386
-
5387
-
5388
-
5389
-
5390
5364
  doOnConnection(nodeServerInstance, clientSocket);
5391
5365
 
5392
5366
 
5393
-
5394
-
5395
5367
  // DBG
5396
5368
  lognow("DEBUG : Starting ping-pong with client : clientSocket.clientId:",clientSocket.clientId);
5397
5369
  lognow("DEBUG : clientSocket.readyState:",clientSocket.readyState);
@@ -5564,31 +5536,24 @@ WebsocketImplementation={
5564
5536
  const receptionEntryPoint={
5565
5537
  channelName:channelName,
5566
5538
  clientsRoomsTag:clientsRoomsTag,
5567
- execute:(clientSocketParam)=>{
5568
-
5569
- const doOnMessage=(eventOrMessage)=>{
5539
+ execute:(eventOrMessage)=>{
5570
5540
 
5571
- // dataWrapped=JSON.parse(dataWrapped);
5572
- // dataWrapped=getAt(dataWrapped,0);// We get the root element
5573
- // const dataWrapped=(WebsocketImplementation.useFlatStrings?JSON.parse(eventOrMessage):eventOrMessage);
5541
+ // dataWrapped=JSON.parse(dataWrapped);
5542
+ // dataWrapped=getAt(dataWrapped,0);// We get the root element
5543
+ // const dataWrapped=(WebsocketImplementation.useFlatStrings?JSON.parse(eventOrMessage):eventOrMessage);
5574
5544
 
5575
- const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
5576
-
5577
- // Channel information is stored in exchanged data :
5578
- if(dataWrapped.channelName && dataWrapped.channelName!==channelName) return;
5579
-
5580
- let clientSocket=nodeClientInstance.clientSocket;
5581
-
5582
- // Room information is stored in client socket object :
5583
- if(!WebsocketImplementation.isInRoom(clientSocket,clientsRoomsTag)) return;
5584
-
5585
- doOnIncomingMessage(dataWrapped.data, clientSocket);
5586
-
5587
- };
5545
+ const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
5546
+
5547
+ // Channel information is stored in exchanged data :
5548
+ if(dataWrapped.channelName && dataWrapped.channelName!==channelName) return;
5549
+
5550
+ const clientSocket=nodeClientInstance.clientSocket;
5551
+
5552
+ // Room information is stored in client socket object :
5553
+ if(!WebsocketImplementation.isInRoom(clientSocket,clientsRoomsTag)) return;
5554
+
5555
+ if(doOnIncomingMessage) doOnIncomingMessage(dataWrapped.data, clientSocket);
5588
5556
 
5589
- if(!WebsocketImplementation.useSocketIOImplementation) nodeClientInstance.clientSocket.addEventListener("message", doOnMessage);
5590
- else nodeClientInstance.clientSocket.on(channelName, doOnMessage);
5591
-
5592
5557
 
5593
5558
  }
5594
5559
  };
@@ -5657,18 +5622,23 @@ WebsocketImplementation={
5657
5622
  if(nodeClientInstance.hasConnectEventFired) return;
5658
5623
  nodeClientInstance.hasConnectEventFired=true;
5659
5624
 
5660
- const clientSocket=nodeClientInstance.clientSocket;
5661
-
5662
-
5663
5625
  // DBG
5664
5626
  lognow("DEBUG : CLIENT : doOnConnection !");
5665
5627
 
5666
- doOnConnection(nodeClientInstance, clientSocket);
5628
+ const doOnMessage=(eventOrMessage)=>{
5629
+
5630
+ // We execute the listeners entry points registration :
5631
+ foreach(nodeClientInstance.receptionEntryPoints,(receptionEntryPoint)=>{
5632
+ receptionEntryPoint.execute(eventOrMessage);
5633
+ });
5634
+
5635
+ };
5667
5636
 
5668
- // We execute the listeners entry points registration :
5669
- foreach(nodeClientInstance.receptionEntryPoints,(receptionEntryPoint)=>{
5670
- receptionEntryPoint.execute(clientSocket);
5671
- });
5637
+ const clientSocket=nodeClientInstance.clientSocket;
5638
+ if(!WebsocketImplementation.useSocketIOImplementation) clientSocket.addEventListener("message", doOnMessage);
5639
+ else clientSocket.on(channelName, doOnMessage);
5640
+
5641
+ doOnConnection(nodeClientInstance, clientSocket);
5672
5642
 
5673
5643
 
5674
5644
  };
@@ -5739,30 +5709,30 @@ WebsocketImplementation={
5739
5709
  // DBG
5740
5710
  lognow("INFO : (CLIENT-BROWSER) SETTING UP RECEIVE for :",channelName);
5741
5711
 
5712
+
5742
5713
  const doOnMessage=(eventOrMessage)=>{
5743
5714
 
5744
-
5745
- const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
5746
-
5747
-
5748
- // Channel information is stored in exchanged data :
5749
- if(dataWrapped.channelName && dataWrapped.channelName!==channelName) return;
5750
-
5751
- let clientSocket=browserInstance.clientSocket;
5752
-
5753
- // Room information is stored in client socket object :
5754
- if(!WebsocketImplementation.isInRoom(clientSocket,clientsRoomsTag)) return;
5755
-
5756
- doOnIncomingMessage(dataWrapped.data, clientSocket);
5757
-
5758
- };
5715
+ const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
5716
+
5717
+
5718
+ // Channel information is stored in exchanged data :
5719
+ if(dataWrapped.channelName && dataWrapped.channelName!==channelName) return;
5720
+
5721
+ const clientSocket=browserInstance.clientSocket;
5722
+
5723
+ // Room information is stored in client socket object :
5724
+ if(!WebsocketImplementation.isInRoom(clientSocket, clientsRoomsTag)) return;
5725
+
5726
+ doOnIncomingMessage(dataWrapped.data, clientSocket);
5727
+
5728
+ };
5759
5729
 
5760
5730
 
5761
- if(!WebsocketImplementation.useSocketIOImplementation) browserInstance.clientSocket.addEventListener("message", doOnMessage);
5762
- else browserInstance.clientSocket.on(channelName, doOnMessage);
5731
+ if(!WebsocketImplementation.useSocketIOImplementation) browserInstance.clientSocket.addEventListener("message", doOnMessage);
5732
+ else browserInstance.clientSocket.on(channelName, doOnMessage);
5763
5733
 
5764
5734
 
5765
- return browserInstance;
5735
+ return browserInstance;
5766
5736
  },
5767
5737
 
5768
5738
 
@@ -5821,7 +5791,6 @@ WebsocketImplementation={
5821
5791
 
5822
5792
 
5823
5793
  doOnConnection(browserInstance, clientSocket);
5824
-
5825
5794
 
5826
5795
  };
5827
5796
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.298",
3
+ "version": "0.0.300",
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)",