aotrautils-srv 0.0.91 → 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-
|
|
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-
|
|
4831
|
+
/*utils SERVER library associated with aotra version : «1.0.0.000 (13/07/2022-23:19:22)»*/
|
|
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,
|
|
@@ -5127,28 +5129,23 @@ WebsocketImplementation={
|
|
|
5127
5129
|
throw new Error("ERROR : SERVER : Server launch is not supported in a non-nodejs context for any implementation.");
|
|
5128
5130
|
}
|
|
5129
5131
|
|
|
5130
|
-
// DBG
|
|
5131
|
-
socketIO=require("socket.io");
|
|
5132
|
-
WebSocket=require("ws");
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
5132
|
|
|
5136
5133
|
|
|
5137
5134
|
// TODO : FIXME : Use one single interface !
|
|
5138
5135
|
// NODE SERVER MODE ONLY :
|
|
5139
5136
|
let serverSocket;
|
|
5140
5137
|
if(!WebsocketImplementation.useSocketIOImplementation){
|
|
5141
|
-
serverSocket=new WebSocket.Server({ "server":listenableServer });
|
|
5138
|
+
serverSocket=new WebsocketImplementation.WebSocket.Server({ "server":listenableServer });
|
|
5142
5139
|
}else{
|
|
5143
5140
|
|
|
5144
5141
|
|
|
5145
5142
|
// DBG
|
|
5146
|
-
console.log(">>>>>>>socketIO:",JSON.stringify(socketIO));
|
|
5147
|
-
console.log(">>>>>>>WebSocket:",JSON.stringify(WebSocket));
|
|
5143
|
+
console.log(">>>>>>>WebsocketImplementation.socketIO:",JSON.stringify(WebsocketImplementation.socketIO));
|
|
5144
|
+
console.log(">>>>>>>WebsocketImplementation.WebSocket:",JSON.stringify(WebsocketImplementation.WebSocket));
|
|
5148
5145
|
|
|
5149
5146
|
// NOW : socket.io :
|
|
5150
5147
|
// Loading socket.io
|
|
5151
|
-
serverSocket=socketIO.listen(listenableServer);
|
|
5148
|
+
serverSocket=WebsocketImplementation.socketIO.listen(listenableServer);
|
|
5152
5149
|
|
|
5153
5150
|
// Setting up the disctonnect event :
|
|
5154
5151
|
serverSocket.on("endConnection",()=>{
|
|
@@ -5236,7 +5233,7 @@ WebsocketImplementation={
|
|
|
5236
5233
|
|
|
5237
5234
|
|
|
5238
5235
|
// TODO : FIXME : Use one single interface !
|
|
5239
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5236
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
|
|
5240
5237
|
else if(clientSocket.connected) return;
|
|
5241
5238
|
|
|
5242
5239
|
|
|
@@ -5260,7 +5257,7 @@ WebsocketImplementation={
|
|
|
5260
5257
|
|
|
5261
5258
|
// TODO : FIXME : Use one single interface !
|
|
5262
5259
|
let clientSocket=clientSocketParam;
|
|
5263
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5260
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
|
|
5264
5261
|
else if(clientSocket.connected) return;
|
|
5265
5262
|
|
|
5266
5263
|
|
|
@@ -5437,7 +5434,7 @@ WebsocketImplementation={
|
|
|
5437
5434
|
|
|
5438
5435
|
|
|
5439
5436
|
// NEW : ws :
|
|
5440
|
-
if(typeof(WebSocket)==="undefined"){
|
|
5437
|
+
if(typeof(WebsocketImplementation.WebSocket)==="undefined"){
|
|
5441
5438
|
// TRACE
|
|
5442
5439
|
lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
|
|
5443
5440
|
return null;
|
|
@@ -5446,18 +5443,18 @@ WebsocketImplementation={
|
|
|
5446
5443
|
// NODE CLIENT MODE ONLY :
|
|
5447
5444
|
let clientSocket;
|
|
5448
5445
|
if(!WebsocketImplementation.useSocketIOImplementation){
|
|
5449
|
-
clientSocket=new WebSocket(serverURL+":"+port,/*WORKAROUND:*/{ rejectUnauthorized:false, secure: isSecure });
|
|
5446
|
+
clientSocket=new WebsocketImplementation.WebSocket(serverURL+":"+port,/*WORKAROUND:*/{ rejectUnauthorized:false, secure: isSecure });
|
|
5450
5447
|
}else{
|
|
5451
5448
|
// NOW : socket.io :
|
|
5452
5449
|
//client on server-side:
|
|
5453
5450
|
|
|
5454
5451
|
|
|
5455
|
-
if(WebsocketImplementation.isNodeContext && typeof(socketIO)!=="undefined"){
|
|
5452
|
+
if(WebsocketImplementation.isNodeContext && typeof(WebsocketImplementation.socketIO)!=="undefined"){
|
|
5456
5453
|
// // Node client :
|
|
5457
5454
|
// connectToServer=function (serverURL, port, isSecure, timeout=10000){
|
|
5458
|
-
// return socketIO.connect(serverURL + ":" + port,{timeout: timeout});
|
|
5455
|
+
// return WebsocketImplementation.socketIO.connect(serverURL + ":" + port,{timeout: timeout});
|
|
5459
5456
|
// }
|
|
5460
|
-
clientSocket=socketIO.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5457
|
+
clientSocket=WebsocketImplementation.socketIO.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5461
5458
|
}
|
|
5462
5459
|
}
|
|
5463
5460
|
|
|
@@ -5517,7 +5514,7 @@ WebsocketImplementation={
|
|
|
5517
5514
|
// console.log("(NODE CLIENT) TRYING TO SEND : clientSocket.readyState:",clientSocket.readyState);
|
|
5518
5515
|
|
|
5519
5516
|
// TODO : FIXME : Use one single interface !
|
|
5520
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5517
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
|
|
5521
5518
|
else if(clientSocket.connected) return;
|
|
5522
5519
|
|
|
5523
5520
|
|
|
@@ -5594,7 +5591,7 @@ WebsocketImplementation={
|
|
|
5594
5591
|
/*private*/connectToServerFromBrowser:(serverURL, port, isSecure, timeout)=>{
|
|
5595
5592
|
|
|
5596
5593
|
// NEW : ws :
|
|
5597
|
-
if(typeof(WebSocket)==="undefined"){
|
|
5594
|
+
if(typeof(WebsocketImplementation.WebSocket)==="undefined"){
|
|
5598
5595
|
// TRACE
|
|
5599
5596
|
lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
|
|
5600
5597
|
return null;
|
|
@@ -5604,7 +5601,7 @@ WebsocketImplementation={
|
|
|
5604
5601
|
// BROWSER CLIENT MODE ONLY :
|
|
5605
5602
|
let clientSocket;
|
|
5606
5603
|
if(!WebsocketImplementation.useSocketIOImplementation){
|
|
5607
|
-
clientSocket=new WebSocket(serverURL+":"+port,["ws","wss"]);
|
|
5604
|
+
clientSocket=new WebsocketImplementation.WebSocket(serverURL+":"+port,["ws","wss"]);
|
|
5608
5605
|
}else if(typeof(io)!=="undefined"){
|
|
5609
5606
|
// NOW : socket.io :
|
|
5610
5607
|
// // Browser client :
|
|
@@ -5670,7 +5667,7 @@ WebsocketImplementation={
|
|
|
5670
5667
|
// console.log("(BROWSER) TRYING TO SEND : clientSocket.readyState:",clientSocket.readyState);
|
|
5671
5668
|
|
|
5672
5669
|
// TODO : FIXME : Use one single interface !
|
|
5673
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5670
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
|
|
5674
5671
|
else if(clientSocket.connected) return;
|
|
5675
5672
|
|
|
5676
5673
|
|
aotrautils-srv/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils-srv",
|
|
3
|
-
"version": "0.0.
|
|
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)",
|