aotrautils-srv 0.0.208 → 0.0.211

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.0.0.000 (19/07/2022-03:08:57)»*/
3
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (19/07/2022-03:36:03)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -4828,7 +4828,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4828
4828
 
4829
4829
 
4830
4830
 
4831
- /*utils SERVER library associated with aotra version : «1.0.0.000 (19/07/2022-03:08:57)»*/
4831
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (19/07/2022-03:36:03)»*/
4832
4832
  /*-----------------------------------------------------------------------------*/
4833
4833
 
4834
4834
 
@@ -5331,12 +5331,16 @@ WebsocketImplementation={
5331
5331
  doOnConnection(nodeServerInstance, clientSocket);
5332
5332
 
5333
5333
 
5334
+ // DBG
5335
+ lognow("DEBUG : Starting ping-pong with client : clientSocket.id:",clientSocket.id);
5336
+
5337
+
5334
5338
  // To make the server aware of the clients connections states :
5339
+ clientSocket.isConnectionAlive=true;
5335
5340
  clientSocket.stateCheckInterval=setInterval(()=>{
5336
5341
 
5337
5342
 
5338
- if (clientSocket.isAlive===false){
5339
- clearInterval(clientSocket.stateCheckInterval);
5343
+ if (clientSocket.isConnectionAlive===false){
5340
5344
 
5341
5345
  // TODO : FIXME : DUPLICATED CODE :
5342
5346
  // TODO : FIXME : Use one single interface !
@@ -5346,35 +5350,37 @@ WebsocketImplementation={
5346
5350
  // TODO : FIXME : DUPLICATED CODE :
5347
5351
  if(!empty(nodeServerInstance.onClientLostListeners))
5348
5352
  foreach(nodeServerInstance.onClientLostListeners,l=>{l.execute(clientSocket);});
5353
+
5349
5354
 
5355
+ clearInterval(clientSocket.stateCheckInterval);
5350
5356
  return;
5351
5357
  }
5352
5358
 
5353
- clientSocket.isAlive=false;
5354
- try{
5359
+ clientSocket.isConnectionAlive=false;
5360
+ // try{
5355
5361
 
5356
5362
  // OLD :
5357
5363
  // if(!WebsocketImplementation.useSocketIOImplementation) clientSocket.ping();
5358
5364
  // else clientSocket.emit("ping");
5359
- nodeServerInstance.send("protocol",{type:"ping"});
5365
+
5366
+ nodeServerInstance.send("protocol",{type:"ping"});
5360
5367
 
5361
-
5362
5368
 
5363
- }catch(error){
5364
- lognow("ERROR : A problem occurred when tried to ping client socket : ",error);
5365
- // We effectively end the client connection to this server :
5366
-
5367
- // TODO : FIXME : DUPLICATED CODE :
5368
- // TODO : FIXME : Use one single interface !
5369
- if(!WebsocketImplementation.useSocketIOImplementation) clientSocket.terminate();
5370
- else clientSocket.emit("endConnection");
5371
-
5372
- // TODO : FIXME : DUPLICATED CODE :
5373
- if(!empty(nodeServerInstance.onClientLostListeners))
5374
- foreach(nodeServerInstance.onClientLostListeners,l=>{l.execute(clientSocket);});
5375
-
5376
- return;
5377
- }
5369
+ // }catch(error){
5370
+ // lognow("ERROR : A problem occurred when tried to ping client socket : ",error);
5371
+ // // We effectively end the client connection to this server :
5372
+ //
5373
+ // // TODO : FIXME : DUPLICATED CODE :
5374
+ // // TODO : FIXME : Use one single interface !
5375
+ // if(!WebsocketImplementation.useSocketIOImplementation) clientSocket.terminate();
5376
+ // else clientSocket.emit("endConnection");
5377
+ //
5378
+ // // TODO : FIXME : DUPLICATED CODE :
5379
+ // if(!empty(nodeServerInstance.onClientLostListeners))
5380
+ // foreach(nodeServerInstance.onClientLostListeners,l=>{l.execute(clientSocket);});
5381
+ //
5382
+ // return;
5383
+ // }
5378
5384
 
5379
5385
 
5380
5386
  }, nodeServerInstance.clientTimeoutMillis);
@@ -5383,17 +5389,17 @@ WebsocketImplementation={
5383
5389
  // // OLD :
5384
5390
  // if(!WebsocketImplementation.useSocketIOImplementation){
5385
5391
  // clientSocket.on("pong",()=>{
5386
- // clientSocket.isAlive=true;
5392
+ // clientSocket.isConnectionAlive=true;
5387
5393
  // });
5388
5394
  // }else{
5389
5395
  // clientSocket.on("ping",()=>{
5390
- // clientSocket.isAlive=true;
5396
+ // clientSocket.isConnectionAlive=true;
5391
5397
  // });
5392
5398
  // }
5393
5399
 
5394
5400
  nodeServerInstance.receive("protocol",(message)=>{
5395
5401
  if(message.type!=="pong") return;
5396
- clientSocket.isAlive=true;
5402
+ clientSocket.isConnectionAlive=true;
5397
5403
  });
5398
5404
 
5399
5405
 
@@ -6157,12 +6163,16 @@ class ListManager{
6157
6163
  lognow("ERROR : Cannot add null item.");
6158
6164
  return;
6159
6165
  }
6160
- const numberOfItemsCurrently=countKeys(this.itemsInfos);
6166
+ const numberOfItemsCurrently=getArraySize(this.itemsInfos);
6161
6167
  if(this.maxItemsNumber<=numberOfItemsCurrently){
6162
6168
  // TRACE
6163
6169
  lognow("ERROR : Cannot add item with id «"+id+"», list already full.");
6164
6170
  return;
6165
6171
  }
6172
+
6173
+ // DBG
6174
+ lognow(">>>>>>>>>numberOfItemsCurrently:",numberOfItemsCurrently);
6175
+
6166
6176
  if(numberOfItemsCurrently==0 && this.mode==="startAtConnexion"){
6167
6177
  this.startSession();
6168
6178
  }
@@ -6188,9 +6198,13 @@ class ListManager{
6188
6198
  }
6189
6199
 
6190
6200
  isClientActive(clientId){
6201
+
6202
+ // DBG
6203
+ lognow(" this.isSessionActive()",this.isSessionActive());
6204
+
6191
6205
  if(!this.isSessionActive()) return false;
6192
6206
  const clientPosition=this.getItemPosition(clientId);
6193
- const result=(clientPosition<=this.maxItemsNumber);
6207
+ const result=((clientPosition-1)/*Because client position starts at 1 !*/<=this.maxItemsNumber);
6194
6208
  return result;
6195
6209
  }
6196
6210
 
@@ -6217,10 +6231,14 @@ class ListManager{
6217
6231
 
6218
6232
  let id=null;
6219
6233
  foreach(this.itemsInfos,(itemInfos,key)=>{
6220
- if(itemInfos.item===item){
6234
+ if(itemInfos.item===item
6235
+ // DEBUG ONLY :
6236
+ || (itemInfos.item.id && item.id && itemInfos.item.id===item.id)
6237
+ ){
6221
6238
  id=key;
6222
6239
  return "break";
6223
6240
  }
6241
+
6224
6242
  });
6225
6243
 
6226
6244
  if(!id){
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.208",
3
+ "version": "0.0.211",
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)",