aotrautils-srv 0.0.73 → 0.0.76

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 SERVER library associated with aotra version : «1.0.0.000 (13/07/2022-02:14:34)»*/
3
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (13/07/2022-02:25:54)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -229,15 +229,16 @@ WebsocketImplementation={
229
229
  // https://stackoverflow.com/questions/6599470/node-js-socket-io-with-ssl
230
230
  // https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
231
231
 
232
- if(typeof(socketIO)==="undefined"){
232
+ const globalContext=(WebsocketImplementation.isNodeContext?global:window);
233
+ if(typeof(globalContext.socketIO)==="undefined"){
233
234
  // TRACE
234
235
  lognow("«socket.io» SERVER library not called yet, calling it now.");
235
- socketIO=require("socket.io");
236
+ globalContext.socketIO=require("socket.io");
236
237
  // TRACE
237
- lognow("«socket.io» SERVER library called.");
238
+ lognow("«socket.io» SERVER library called:",globalContext.socketIO);
238
239
 
239
240
  }
240
- if(typeof(socketIO)==="undefined"){
241
+ if(typeof(globalContext.socketIO)==="undefined"){
241
242
  // Exception
242
243
  throw "ERROR : «socket.io» SERVER library not found. Cannot launch nodejs server. Aborting.";
243
244
  }
@@ -285,13 +286,14 @@ WebsocketImplementation={
285
286
  serverSocket=new WebSocket.Server({ "server":listenableServer });
286
287
  }else{
287
288
 
288
-
289
+ const globalContext=(WebsocketImplementation.isNodeContext?global:window);
290
+
289
291
  // DBG
290
- console.log(">>>>>>>socketIO:",JSON.stringify(socketIO));
292
+ console.log(">>>>>>>socketIO:",JSON.stringify(globalContext.socketIO));
291
293
 
292
294
  // NOW : socket.io :
293
295
  // Loading socket.io
294
- serverSocket=socketIO.listen(listenableServer);
296
+ serverSocket=globalContext.socketIO.listen(listenableServer);
295
297
 
296
298
  // Setting up the disctonnect event :
297
299
  serverSocket.on("endConnection",()=>{
@@ -593,12 +595,15 @@ WebsocketImplementation={
593
595
  }else{
594
596
  // NOW : socket.io :
595
597
  //client on server-side:
596
- if(WebsocketImplementation.isNodeContext && typeof(socketIO)!=="undefined"){
598
+
599
+ const globalContext=(WebsocketImplementation.isNodeContext?global:window);
600
+
601
+ if(WebsocketImplementation.isNodeContext && typeof(globalContext.socketIO)!=="undefined"){
597
602
  // // Node client :
598
603
  // connectToServer=function (serverURL, port, isSecure, timeout=10000){
599
604
  // return socketIO.connect(serverURL + ":" + port,{timeout: timeout});
600
605
  // }
601
- clientSocket=socketIO.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
606
+ clientSocket=globalContext.socketIO.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
602
607
  }
603
608
  }
604
609
 
@@ -1317,7 +1322,7 @@ function getListManager(config){
1317
1322
 
1318
1323
 
1319
1324
 
1320
- /*utils COMMONS library associated with aotra version : «1.0.0.000 (13/07/2022-02:14:34)»*/
1325
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (13/07/2022-02:25:54)»*/
1321
1326
  /*-----------------------------------------------------------------------------*/
1322
1327
 
1323
1328
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.73",
3
+ "version": "0.0.76",
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)",