aotrautils-srv 0.0.89 → 0.0.92

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:25:30)»*/
3
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (13/07/2022-23:19:22)»*/
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:25:30)»*/
4831
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (13/07/2022-23:19:22)»*/
4832
4832
  /*-----------------------------------------------------------------------------*/
4833
4833
 
4834
4834
 
@@ -4863,8 +4863,8 @@ if(typeof(window)==="undefined") window=global;
4863
4863
  // https://stackoverflow.com/questions/6599470/node-js-socket-io-with-ssl
4864
4864
  // https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
4865
4865
 
4866
- const socketIO=require("socket.io");;
4867
- const WebSocket=require("ws");;
4866
+
4867
+
4868
4868
 
4869
4869
  //let socketIO;
4870
4870
  //let WebSocket;
@@ -5075,6 +5075,12 @@ if(typeof(fs)==="undefined"){
5075
5075
  // NODE ONLY SERVER / CLIENTS :
5076
5076
  WebsocketImplementation={
5077
5077
 
5078
+ ////
5079
+
5080
+ socketIO:require("socket.io"),
5081
+ WebSocket:require("ws"),
5082
+
5083
+
5078
5084
  isNodeContext:true,
5079
5085
  useSocketIOImplementation:false,
5080
5086
  useFlatStrings:false,
@@ -5123,21 +5129,23 @@ WebsocketImplementation={
5123
5129
  throw new Error("ERROR : SERVER : Server launch is not supported in a non-nodejs context for any implementation.");
5124
5130
  }
5125
5131
 
5132
+
5133
+
5126
5134
  // TODO : FIXME : Use one single interface !
5127
5135
  // NODE SERVER MODE ONLY :
5128
5136
  let serverSocket;
5129
5137
  if(!WebsocketImplementation.useSocketIOImplementation){
5130
- serverSocket=new WebSocket.Server({ "server":listenableServer });
5138
+ serverSocket=new WebsocketImplementation.WebSocket.Server({ "server":listenableServer });
5131
5139
  }else{
5132
5140
 
5133
5141
 
5134
5142
  // DBG
5135
- console.log(">>>>>>>socketIO:",JSON.stringify(socketIO));
5136
- console.log(">>>>>>>WebSocket:",JSON.stringify(WebSocket));
5143
+ console.log(">>>>>>>WebsocketImplementation.socketIO:",JSON.stringify(WebsocketImplementation.socketIO));
5144
+ console.log(">>>>>>>WebsocketImplementation.WebSocket:",JSON.stringify(WebsocketImplementation.WebSocket));
5137
5145
 
5138
5146
  // NOW : socket.io :
5139
5147
  // Loading socket.io
5140
- serverSocket=socketIO.listen(listenableServer);
5148
+ serverSocket=WebsocketImplementation.socketIO.listen(listenableServer);
5141
5149
 
5142
5150
  // Setting up the disctonnect event :
5143
5151
  serverSocket.on("endConnection",()=>{
@@ -5225,7 +5233,7 @@ WebsocketImplementation={
5225
5233
 
5226
5234
 
5227
5235
  // TODO : FIXME : Use one single interface !
5228
- if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
5236
+ if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
5229
5237
  else if(clientSocket.connected) return;
5230
5238
 
5231
5239
 
@@ -5249,7 +5257,7 @@ WebsocketImplementation={
5249
5257
 
5250
5258
  // TODO : FIXME : Use one single interface !
5251
5259
  let clientSocket=clientSocketParam;
5252
- if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
5260
+ if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
5253
5261
  else if(clientSocket.connected) return;
5254
5262
 
5255
5263
 
@@ -5426,7 +5434,7 @@ WebsocketImplementation={
5426
5434
 
5427
5435
 
5428
5436
  // NEW : ws :
5429
- if(typeof(WebSocket)==="undefined"){
5437
+ if(typeof(WebsocketImplementation.WebSocket)==="undefined"){
5430
5438
  // TRACE
5431
5439
  lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
5432
5440
  return null;
@@ -5435,18 +5443,18 @@ WebsocketImplementation={
5435
5443
  // NODE CLIENT MODE ONLY :
5436
5444
  let clientSocket;
5437
5445
  if(!WebsocketImplementation.useSocketIOImplementation){
5438
- clientSocket=new WebSocket(serverURL+":"+port,/*WORKAROUND:*/{ rejectUnauthorized:false, secure: isSecure });
5446
+ clientSocket=new WebsocketImplementation.WebSocket(serverURL+":"+port,/*WORKAROUND:*/{ rejectUnauthorized:false, secure: isSecure });
5439
5447
  }else{
5440
5448
  // NOW : socket.io :
5441
5449
  //client on server-side:
5442
5450
 
5443
5451
 
5444
- if(WebsocketImplementation.isNodeContext && typeof(socketIO)!=="undefined"){
5452
+ if(WebsocketImplementation.isNodeContext && typeof(WebsocketImplementation.socketIO)!=="undefined"){
5445
5453
  // // Node client :
5446
5454
  // connectToServer=function (serverURL, port, isSecure, timeout=10000){
5447
- // return socketIO.connect(serverURL + ":" + port,{timeout: timeout});
5455
+ // return WebsocketImplementation.socketIO.connect(serverURL + ":" + port,{timeout: timeout});
5448
5456
  // }
5449
- clientSocket=socketIO.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5457
+ clientSocket=WebsocketImplementation.socketIO.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5450
5458
  }
5451
5459
  }
5452
5460
 
@@ -5506,7 +5514,7 @@ WebsocketImplementation={
5506
5514
  // console.log("(NODE CLIENT) TRYING TO SEND : clientSocket.readyState:",clientSocket.readyState);
5507
5515
 
5508
5516
  // TODO : FIXME : Use one single interface !
5509
- if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
5517
+ if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
5510
5518
  else if(clientSocket.connected) return;
5511
5519
 
5512
5520
 
@@ -5583,7 +5591,7 @@ WebsocketImplementation={
5583
5591
  /*private*/connectToServerFromBrowser:(serverURL, port, isSecure, timeout)=>{
5584
5592
 
5585
5593
  // NEW : ws :
5586
- if(typeof(WebSocket)==="undefined"){
5594
+ if(typeof(WebsocketImplementation.WebSocket)==="undefined"){
5587
5595
  // TRACE
5588
5596
  lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
5589
5597
  return null;
@@ -5593,7 +5601,7 @@ WebsocketImplementation={
5593
5601
  // BROWSER CLIENT MODE ONLY :
5594
5602
  let clientSocket;
5595
5603
  if(!WebsocketImplementation.useSocketIOImplementation){
5596
- clientSocket=new WebSocket(serverURL+":"+port,["ws","wss"]);
5604
+ clientSocket=new WebsocketImplementation.WebSocket(serverURL+":"+port,["ws","wss"]);
5597
5605
  }else if(typeof(io)!=="undefined"){
5598
5606
  // NOW : socket.io :
5599
5607
  // // Browser client :
@@ -5659,7 +5667,7 @@ WebsocketImplementation={
5659
5667
  // console.log("(BROWSER) TRYING TO SEND : clientSocket.readyState:",clientSocket.readyState);
5660
5668
 
5661
5669
  // TODO : FIXME : Use one single interface !
5662
- if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
5670
+ if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
5663
5671
  else if(clientSocket.connected) return;
5664
5672
 
5665
5673
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.89",
3
+ "version": "0.0.92",
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)",