aotrautils-srv 0.0.207 → 0.0.210

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:02:07)»*/
3
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (19/07/2022-03:27:06)»*/
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:02:07)»*/
4831
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (19/07/2022-03:27:06)»*/
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
 
@@ -6188,9 +6194,13 @@ class ListManager{
6188
6194
  }
6189
6195
 
6190
6196
  isClientActive(clientId){
6197
+
6198
+ // DBG
6199
+ lognow(" this.isSessionActive()",this.isSessionActive());
6200
+
6191
6201
  if(!this.isSessionActive()) return false;
6192
6202
  const clientPosition=this.getItemPosition(clientId);
6193
- const result=(clientPosition<=this.maxItemsNumber);
6203
+ const result=((clientPosition-1)/*Because client position starts at 1 !*/<=this.maxItemsNumber);
6194
6204
  return result;
6195
6205
  }
6196
6206
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.207",
3
+ "version": "0.0.210",
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)",