aotrautils-srv 0.0.128 → 0.0.129

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:04:32)»*/
3
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (16/07/2022-16:26:34)»*/
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:04:32)»*/
4831
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (16/07/2022-16:26:34)»*/
4832
4832
  /*-----------------------------------------------------------------------------*/
4833
4833
 
4834
4834
 
@@ -4872,10 +4872,8 @@ if(typeof(window)==="undefined") window=global;
4872
4872
  // https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications
4873
4873
 
4874
4874
  // We have to import both implementations, regardless of which one is chosen :
4875
- //const {Socket}=require("socket.io");
4876
- //const {WebSocket}=require("ws");
4877
- Socket=require("socket.io");
4878
- WebSocket=require("ws");
4875
+ //Socket=require("socket.io");
4876
+ //WebSocket=require("ws");
4879
4877
 
4880
4878
 
4881
4879
 
@@ -5066,21 +5064,46 @@ WebsocketImplementation={
5066
5064
  getStatic:(isNodeContext=true, useSocketIOImplementation=false)=>{
5067
5065
 
5068
5066
  WebsocketImplementation.isNodeContext=isNodeContext;
5069
-
5070
5067
  WebsocketImplementation.useSocketIOImplementation=useSocketIOImplementation;
5071
5068
 
5072
5069
  if(WebsocketImplementation.useSocketIOImplementation){
5073
5070
  // TRACE
5074
5071
  lognow("INFO : (SERVER/CLIENT) Using socket.io websocket implementation.");
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;
5083
+ }
5075
5084
 
5076
5085
  }else{
5077
5086
  // TRACE
5078
- lognow("INFO : (SERVER/CLIENT) Using native websocket implementation.");
5087
+ lognow("INFO : (SERVER/CLIENT) Using native WebSocket implementation.");
5088
+
5089
+ // 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;
5095
+ }
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
+ }
5079
5101
 
5080
5102
  }
5103
+
5081
5104
 
5082
5105
  // *********************************************************************************
5083
-
5106
+
5084
5107
 
5085
5108
  return WebsocketImplementation;
5086
5109
  },
@@ -5576,7 +5599,9 @@ WebsocketImplementation={
5576
5599
  // }else{
5577
5600
  // // TRACE
5578
5601
  // console.log("ERROR : Could not initialize socket !");
5579
- clientSocket=io.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5602
+ // OLD SYNTAX :clientSocket=io.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5603
+ clientSocket=Socket(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5604
+
5580
5605
  }
5581
5606
 
5582
5607
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.128",
3
+ "version": "0.0.129",
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)",