aotrautils-srv 0.0.90 → 0.0.93

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 (13/07/2022-11:27:48)»*/
3
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (13/07/2022-23:23:15)»*/
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 (13/07/2022-11:27:48)»*/
4831
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (13/07/2022-23:23:15)»*/
4832
4832
  /*-----------------------------------------------------------------------------*/
4833
4833
 
4834
4834
 
@@ -4864,10 +4864,6 @@ if(typeof(window)==="undefined") window=global;
4864
4864
  // https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
4865
4865
 
4866
4866
 
4867
- // DBG
4868
- socketIO=require("socket.io");
4869
- WebSocket=require("ws");
4870
-
4871
4867
 
4872
4868
 
4873
4869
  //let socketIO;
@@ -5079,6 +5075,12 @@ if(typeof(fs)==="undefined"){
5079
5075
  // NODE ONLY SERVER / CLIENTS :
5080
5076
  WebsocketImplementation={
5081
5077
 
5078
+ ////
5079
+
5080
+ socketIO:require("socket.io"),
5081
+ WebSocket:require("ws"),
5082
+
5083
+
5082
5084
  isNodeContext:true,
5083
5085
  useSocketIOImplementation:false,
5084
5086
  useFlatStrings:false,
@@ -5114,6 +5116,10 @@ WebsocketImplementation={
5114
5116
 
5115
5117
  // *********************************************************************************
5116
5118
 
5119
+ WebsocketImplementation.socketIO=require("socket.io");
5120
+ WebsocketImplementation.WebSocket=require("ws");
5121
+
5122
+
5117
5123
 
5118
5124
 
5119
5125
  return WebsocketImplementation;
@@ -5127,21 +5133,23 @@ WebsocketImplementation={
5127
5133
  throw new Error("ERROR : SERVER : Server launch is not supported in a non-nodejs context for any implementation.");
5128
5134
  }
5129
5135
 
5136
+
5137
+
5130
5138
  // TODO : FIXME : Use one single interface !
5131
5139
  // NODE SERVER MODE ONLY :
5132
5140
  let serverSocket;
5133
5141
  if(!WebsocketImplementation.useSocketIOImplementation){
5134
- serverSocket=new WebSocket.Server({ "server":listenableServer });
5142
+ serverSocket=new WebsocketImplementation.WebSocket.Server({ "server":listenableServer });
5135
5143
  }else{
5136
5144
 
5137
5145
 
5138
5146
  // DBG
5139
- console.log(">>>>>>>socketIO:",JSON.stringify(socketIO));
5140
- console.log(">>>>>>>WebSocket:",JSON.stringify(WebSocket));
5147
+ console.log(">>>>>>>WebsocketImplementation.socketIO:",JSON.stringify(WebsocketImplementation.socketIO));
5148
+ console.log(">>>>>>>WebsocketImplementation.WebSocket:",JSON.stringify(WebsocketImplementation.WebSocket));
5141
5149
 
5142
5150
  // NOW : socket.io :
5143
5151
  // Loading socket.io
5144
- serverSocket=socketIO.listen(listenableServer);
5152
+ serverSocket=WebsocketImplementation.socketIO.listen(listenableServer);
5145
5153
 
5146
5154
  // Setting up the disctonnect event :
5147
5155
  serverSocket.on("endConnection",()=>{
@@ -5229,7 +5237,7 @@ WebsocketImplementation={
5229
5237
 
5230
5238
 
5231
5239
  // TODO : FIXME : Use one single interface !
5232
- if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
5240
+ if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
5233
5241
  else if(clientSocket.connected) return;
5234
5242
 
5235
5243
 
@@ -5253,7 +5261,7 @@ WebsocketImplementation={
5253
5261
 
5254
5262
  // TODO : FIXME : Use one single interface !
5255
5263
  let clientSocket=clientSocketParam;
5256
- if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
5264
+ if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
5257
5265
  else if(clientSocket.connected) return;
5258
5266
 
5259
5267
 
@@ -5430,7 +5438,7 @@ WebsocketImplementation={
5430
5438
 
5431
5439
 
5432
5440
  // NEW : ws :
5433
- if(typeof(WebSocket)==="undefined"){
5441
+ if(typeof(WebsocketImplementation.WebSocket)==="undefined"){
5434
5442
  // TRACE
5435
5443
  lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
5436
5444
  return null;
@@ -5439,18 +5447,18 @@ WebsocketImplementation={
5439
5447
  // NODE CLIENT MODE ONLY :
5440
5448
  let clientSocket;
5441
5449
  if(!WebsocketImplementation.useSocketIOImplementation){
5442
- clientSocket=new WebSocket(serverURL+":"+port,/*WORKAROUND:*/{ rejectUnauthorized:false, secure: isSecure });
5450
+ clientSocket=new WebsocketImplementation.WebSocket(serverURL+":"+port,/*WORKAROUND:*/{ rejectUnauthorized:false, secure: isSecure });
5443
5451
  }else{
5444
5452
  // NOW : socket.io :
5445
5453
  //client on server-side:
5446
5454
 
5447
5455
 
5448
- if(WebsocketImplementation.isNodeContext && typeof(socketIO)!=="undefined"){
5456
+ if(WebsocketImplementation.isNodeContext && typeof(WebsocketImplementation.socketIO)!=="undefined"){
5449
5457
  // // Node client :
5450
5458
  // connectToServer=function (serverURL, port, isSecure, timeout=10000){
5451
- // return socketIO.connect(serverURL + ":" + port,{timeout: timeout});
5459
+ // return WebsocketImplementation.socketIO.connect(serverURL + ":" + port,{timeout: timeout});
5452
5460
  // }
5453
- clientSocket=socketIO.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5461
+ clientSocket=WebsocketImplementation.socketIO.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5454
5462
  }
5455
5463
  }
5456
5464
 
@@ -5510,7 +5518,7 @@ WebsocketImplementation={
5510
5518
  // console.log("(NODE CLIENT) TRYING TO SEND : clientSocket.readyState:",clientSocket.readyState);
5511
5519
 
5512
5520
  // TODO : FIXME : Use one single interface !
5513
- if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
5521
+ if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
5514
5522
  else if(clientSocket.connected) return;
5515
5523
 
5516
5524
 
@@ -5587,7 +5595,7 @@ WebsocketImplementation={
5587
5595
  /*private*/connectToServerFromBrowser:(serverURL, port, isSecure, timeout)=>{
5588
5596
 
5589
5597
  // NEW : ws :
5590
- if(typeof(WebSocket)==="undefined"){
5598
+ if(typeof(WebsocketImplementation.WebSocket)==="undefined"){
5591
5599
  // TRACE
5592
5600
  lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
5593
5601
  return null;
@@ -5597,7 +5605,7 @@ WebsocketImplementation={
5597
5605
  // BROWSER CLIENT MODE ONLY :
5598
5606
  let clientSocket;
5599
5607
  if(!WebsocketImplementation.useSocketIOImplementation){
5600
- clientSocket=new WebSocket(serverURL+":"+port,["ws","wss"]);
5608
+ clientSocket=new WebsocketImplementation.WebSocket(serverURL+":"+port,["ws","wss"]);
5601
5609
  }else if(typeof(io)!=="undefined"){
5602
5610
  // NOW : socket.io :
5603
5611
  // // Browser client :
@@ -5663,7 +5671,7 @@ WebsocketImplementation={
5663
5671
  // console.log("(BROWSER) TRYING TO SEND : clientSocket.readyState:",clientSocket.readyState);
5664
5672
 
5665
5673
  // TODO : FIXME : Use one single interface !
5666
- if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
5674
+ if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
5667
5675
  else if(clientSocket.connected) return;
5668
5676
 
5669
5677
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.90",
3
+ "version": "0.0.93",
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)",