aotrautils-srv 0.0.129 → 0.0.132

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 (16/07/2022-16:26:34)»*/
3
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (16/07/2022-16:58:53)»*/
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 (16/07/2022-16:26:34)»*/
4831
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (16/07/2022-16:58:53)»*/
4832
4832
  /*-----------------------------------------------------------------------------*/
4833
4833
 
4834
4834
 
@@ -5070,16 +5070,18 @@ WebsocketImplementation={
5070
5070
  // TRACE
5071
5071
  lognow("INFO : (SERVER/CLIENT) Using socket.io websocket implementation.");
5072
5072
 
5073
- if(isNodeContext && typeof(Socket)==="undefined"){
5074
- // TRACE
5075
- console.log("«socket.io» SERVER library not called yet, calling it now.");
5076
- Socket=require("socket.io");
5077
- return WebsocketImplementation;
5078
- }
5079
- if(typeof(Socket)==="undefined"){
5080
- // TRACE
5081
- console.log("ERROR : «socket.io» CONSOLE/BROWSER CLIENT/SERVER library not found. Cannot launch nodejs server. Aborting.");
5082
- return WebsocketImplementation;
5073
+ if(isNodeContext){
5074
+ if(typeof(Socket)==="undefined"){
5075
+ // TRACE
5076
+ console.log("«socket.io» SERVER library not called yet, calling it now.");
5077
+ Socket=require("socket.io");
5078
+ return WebsocketImplementation;
5079
+ }
5080
+ if(typeof(Socket)==="undefined"){
5081
+ // TRACE
5082
+ console.log("ERROR : «socket.io» CONSOLE/BROWSER CLIENT/SERVER library not found. Cannot launch nodejs server. Aborting.");
5083
+ return WebsocketImplementation;
5084
+ }
5083
5085
  }
5084
5086
 
5085
5087
  }else{
@@ -5087,17 +5089,19 @@ WebsocketImplementation={
5087
5089
  lognow("INFO : (SERVER/CLIENT) Using native WebSocket implementation.");
5088
5090
 
5089
5091
  // https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications
5090
- if(isNodeContext && typeof(WebSocket)==="undefined"){
5091
- WebSocket=require("ws");
5092
- // TRACE
5093
- console.log("«ws» SERVER library not called yet, calling it now.");
5094
- return WebsocketImplementation;
5092
+ if(isNodeContext){
5093
+ if(typeof(WebSocket)==="undefined"){
5094
+ WebSocket=require("ws");
5095
+ // TRACE
5096
+ console.log("«ws» SERVER library not called yet, calling it now.");
5097
+ return WebsocketImplementation;
5098
+ }
5099
+ if(typeof(WebSocket)==="undefined"){
5100
+ // TRACE
5101
+ console.log("ERROR : «ws» CONSOLE/BROWSER CLIENT/SERVER library not found. Cannot launch nodejs server. Aborting.");
5102
+ return WebsocketImplementation;
5103
+ }
5095
5104
  }
5096
- if(typeof(WebSocket)==="undefined"){
5097
- // TRACE
5098
- console.log("ERROR : «ws» CONSOLE/BROWSER CLIENT/SERVER library not found. Cannot launch nodejs server. Aborting.");
5099
- return WebsocketImplementation;
5100
- }
5101
5105
 
5102
5106
  }
5103
5107
 
@@ -5319,7 +5323,10 @@ WebsocketImplementation={
5319
5323
 
5320
5324
  clientSocket.isAlive=false;
5321
5325
  try{
5322
- clientSocket.ping();
5326
+
5327
+ if(!WebsocketImplementation.useSocketIOImplementation) clientSocket.ping();
5328
+ else clientSocket.emit("ping");
5329
+
5323
5330
  }catch(error){
5324
5331
  lognow("ERROR : A problem occurred when tried to ping client socket : ",error);
5325
5332
  // We effectively end the client connection to this server :
@@ -5338,9 +5345,16 @@ WebsocketImplementation={
5338
5345
 
5339
5346
 
5340
5347
  }, nodeServerInstance.clientTimeoutMillis);
5341
- clientSocket.on("pong",()=>{
5342
- clientSocket.isAlive=true;
5343
- });
5348
+
5349
+ if(!WebsocketImplementation.useSocketIOImplementation){
5350
+ clientSocket.on("pong",()=>{
5351
+ clientSocket.isAlive=true;
5352
+ });
5353
+ }else{
5354
+ clientSocket.on("ping",()=>{
5355
+ clientSocket.isAlive=true;
5356
+ });
5357
+ }
5344
5358
 
5345
5359
 
5346
5360
 
@@ -5417,7 +5431,6 @@ WebsocketImplementation={
5417
5431
  /*private*/connectToServerFromNode:(serverURL, port, isSecure, timeout)=>{
5418
5432
 
5419
5433
 
5420
-
5421
5434
  // NEW : ws :
5422
5435
  if(typeof(WebSocket)==="undefined"){
5423
5436
  // TRACE
@@ -5440,7 +5453,8 @@ WebsocketImplementation={
5440
5453
  // }
5441
5454
 
5442
5455
  // OLD SYNTAX: clientSocket=Socket.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5443
- clientSocket=Socket(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5456
+ // clientSocket=new Socket.Client???(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5457
+ clientSocket=io(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5444
5458
 
5445
5459
  }
5446
5460
  }
@@ -5600,7 +5614,7 @@ WebsocketImplementation={
5600
5614
  // // TRACE
5601
5615
  // console.log("ERROR : Could not initialize socket !");
5602
5616
  // OLD SYNTAX :clientSocket=io.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5603
- clientSocket=Socket(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5617
+ clientSocket=io(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5604
5618
 
5605
5619
  }
5606
5620
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.129",
3
+ "version": "0.0.132",
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)",