aotrautils-srv 0.0.114 → 0.0.117

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-14:36:04)»*/
3
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (16/07/2022-14:54:41)»*/
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-14:36:04)»*/
4831
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (16/07/2022-14:54:41)»*/
4832
4832
  /*-----------------------------------------------------------------------------*/
4833
4833
 
4834
4834
 
@@ -4872,13 +4872,16 @@ 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");
4875
+ //const {Socket}=require("socket.io");
4876
+ //const {WebSocket}=require("ws");
4877
+ Socket=require("socket.io");
4878
+ WebSocket=require("ws");
4879
+
4877
4880
 
4878
4881
 
4879
4882
  // DBG
4880
- console.log("Socket!!!!!!",Socket);
4881
- console.log("WebSocket!!!!!!",WebSocket);
4883
+ console.log("Socket!!!!!!>>>>",Socket);
4884
+ console.log("WebSocket!!!!!!>>>>",WebSocket);
4882
4885
 
4883
4886
 
4884
4887
  // =================================================================================
@@ -5050,6 +5053,8 @@ if(typeof(fs)==="undefined"){
5050
5053
  // NODE ONLY SERVER / CLIENTS :
5051
5054
  WebsocketImplementation={
5052
5055
 
5056
+ Socket:Socket,
5057
+ Websocket:WebSocket,
5053
5058
 
5054
5059
  isNodeContext:true,
5055
5060
  useSocketIOImplementation:false,
@@ -5083,8 +5088,10 @@ WebsocketImplementation={
5083
5088
  // *********************************************************************************
5084
5089
 
5085
5090
  // DBG
5086
- console.log("11111 Socket:",JSON.stringify(Socket));
5087
- console.log("11111 WebSocket:",JSON.stringify(WebSocket));
5091
+ console.log("11111 WebsocketImplementation.Socket:",WebsocketImplementation.Socket);
5092
+ console.log("11111 WebsocketImplementation.WebSocket:",WebsocketImplementation.WebSocket);
5093
+ console.log("11111 WebsocketImplementation.Socket:",JSON.stringify(WebsocketImplementation.Socket));
5094
+ console.log("11111 WebsocketImplementation.WebSocket:",JSON.stringify(WebsocketImplementation.WebSocket));
5088
5095
 
5089
5096
 
5090
5097
  return WebsocketImplementation;
@@ -5104,17 +5111,17 @@ WebsocketImplementation={
5104
5111
  // NODE SERVER MODE ONLY :
5105
5112
  let serverSocket;
5106
5113
  if(!WebsocketImplementation.useSocketIOImplementation){
5107
- serverSocket=new WebSocket.Server({ "server":listenableServer });
5114
+ serverSocket=new WebsocketImplementation.WebSocket.Server({ "server":listenableServer });
5108
5115
  }else{
5109
5116
 
5110
5117
 
5111
5118
  // DBG
5112
- console.log(">>>>>>>Socket:",JSON.stringify(Socket));
5113
- console.log(">>>>>>>WebSocket:",JSON.stringify(WebSocket));
5119
+ console.log(">>>>>>>WebsocketImplementation.Socket:",JSON.stringify(WebsocketImplementation.Socket));
5120
+ console.log(">>>>>>>WebsocketImplementation.WebSocket:",JSON.stringify(WebsocketImplementation.WebSocket));
5114
5121
 
5115
5122
  // NOW : socket.io :
5116
5123
  // Loading socket.io
5117
- serverSocket=Socket.listen(listenableServer);
5124
+ serverSocket=WebsocketImplementation.Socket.listen(listenableServer);
5118
5125
 
5119
5126
  // Setting up the disctonnect event :
5120
5127
  serverSocket.on("endConnection",()=>{
@@ -5202,7 +5209,7 @@ WebsocketImplementation={
5202
5209
 
5203
5210
 
5204
5211
  // TODO : FIXME : Use one single interface !
5205
- if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
5212
+ if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
5206
5213
  else if(clientSocket.connected) return;
5207
5214
 
5208
5215
 
@@ -5226,7 +5233,7 @@ WebsocketImplementation={
5226
5233
 
5227
5234
  // TODO : FIXME : Use one single interface !
5228
5235
  let clientSocket=clientSocketParam;
5229
- if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
5236
+ if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
5230
5237
  else if(clientSocket.connected) return;
5231
5238
 
5232
5239
 
@@ -5403,7 +5410,7 @@ WebsocketImplementation={
5403
5410
 
5404
5411
 
5405
5412
  // NEW : ws :
5406
- if(typeof(WebSocket)==="undefined"){
5413
+ if(typeof(WebsocketImplementation.WebSocket)==="undefined"){
5407
5414
  // TRACE
5408
5415
  lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
5409
5416
  return null;
@@ -5412,17 +5419,17 @@ WebsocketImplementation={
5412
5419
  // NODE CLIENT MODE ONLY :
5413
5420
  let clientSocket;
5414
5421
  if(!WebsocketImplementation.useSocketIOImplementation){
5415
- clientSocket=new WebSocket(serverURL+":"+port,/*WORKAROUND:*/{ rejectUnauthorized:false, secure: isSecure });
5422
+ clientSocket=new WebsocketImplementation.WebSocket(serverURL+":"+port,/*WORKAROUND:*/{ rejectUnauthorized:false, secure: isSecure });
5416
5423
  }else{
5417
5424
  // NOW : socket.io :
5418
5425
  //client on server-side:
5419
5426
 
5420
- if(WebsocketImplementation.isNodeContext && typeof(Socket)!=="undefined"){
5427
+ if(WebsocketImplementation.isNodeContext && typeof(WebsocketImplementation.Socket)!=="undefined"){
5421
5428
  // // Node client :
5422
5429
  // connectToServer=function (serverURL, port, isSecure, timeout=10000){
5423
- // return Socket.connect(serverURL + ":" + port,{timeout: timeout});
5430
+ // return WebsocketImplementation.Socket.connect(serverURL + ":" + port,{timeout: timeout});
5424
5431
  // }
5425
- clientSocket=Socket.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5432
+ clientSocket=WebsocketImplementation.Socket.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
5426
5433
  }
5427
5434
  }
5428
5435
 
@@ -5482,7 +5489,7 @@ WebsocketImplementation={
5482
5489
  // console.log("(NODE CLIENT) TRYING TO SEND : clientSocket.readyState:",clientSocket.readyState);
5483
5490
 
5484
5491
  // TODO : FIXME : Use one single interface !
5485
- if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
5492
+ if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
5486
5493
  else if(clientSocket.connected) return;
5487
5494
 
5488
5495
 
@@ -5559,7 +5566,7 @@ WebsocketImplementation={
5559
5566
  /*private*/connectToServerFromBrowser:(serverURL, port, isSecure, timeout)=>{
5560
5567
 
5561
5568
  // NEW : ws :
5562
- if(typeof(WebSocket)==="undefined"){
5569
+ if(typeof(WebsocketImplementation.WebSocket)==="undefined"){
5563
5570
  // TRACE
5564
5571
  lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
5565
5572
  return null;
@@ -5569,7 +5576,7 @@ WebsocketImplementation={
5569
5576
  // BROWSER CLIENT MODE ONLY :
5570
5577
  let clientSocket;
5571
5578
  if(!WebsocketImplementation.useSocketIOImplementation){
5572
- clientSocket=new WebSocket(serverURL+":"+port,["ws","wss"]);
5579
+ clientSocket=new WebsocketImplementation.WebSocket(serverURL+":"+port,["ws","wss"]);
5573
5580
  }else if(typeof(io)!=="undefined"){
5574
5581
  // NOW : socket.io :
5575
5582
  // // Browser client :
@@ -5635,7 +5642,7 @@ WebsocketImplementation={
5635
5642
  // console.log("(BROWSER) TRYING TO SEND : clientSocket.readyState:",clientSocket.readyState);
5636
5643
 
5637
5644
  // TODO : FIXME : Use one single interface !
5638
- if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
5645
+ if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
5639
5646
  else if(clientSocket.connected) return;
5640
5647
 
5641
5648
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.114",
3
+ "version": "0.0.117",
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)",