aotrautils-srv 0.0.91 → 0.0.94
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:24:00)»*/
|
|
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:24:00)»*/
|
|
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,28 +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
|
|
|
5130
|
-
// DBG
|
|
5131
|
-
socketIO=require("socket.io");
|
|
5132
|
-
WebSocket=require("ws");
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
5136
|
|
|
5136
5137
|
|
|
5137
5138
|
// TODO : FIXME : Use one single interface !
|
|
5138
5139
|
// NODE SERVER MODE ONLY :
|
|
5139
5140
|
let serverSocket;
|
|
5140
5141
|
if(!WebsocketImplementation.useSocketIOImplementation){
|
|
5141
|
-
serverSocket=new WebSocket.Server({ "server":listenableServer });
|
|
5142
|
+
serverSocket=new WebsocketImplementation.WebSocket.Server({ "server":listenableServer });
|
|
5142
5143
|
}else{
|
|
5143
5144
|
|
|
5144
5145
|
|
|
5145
5146
|
// DBG
|
|
5146
|
-
console.log(">>>>>>>socketIO:",JSON.stringify(socketIO));
|
|
5147
|
-
console.log(">>>>>>>WebSocket:",JSON.stringify(WebSocket));
|
|
5147
|
+
console.log(">>>>>>>WebsocketImplementation.socketIO:",JSON.stringify(WebsocketImplementation.socketIO));
|
|
5148
|
+
console.log(">>>>>>>WebsocketImplementation.WebSocket:",JSON.stringify(WebsocketImplementation.WebSocket));
|
|
5148
5149
|
|
|
5149
5150
|
// NOW : socket.io :
|
|
5150
5151
|
// Loading socket.io
|
|
5151
|
-
serverSocket=socketIO.listen(listenableServer);
|
|
5152
|
+
serverSocket=WebsocketImplementation.socketIO.listen(listenableServer);
|
|
5152
5153
|
|
|
5153
5154
|
// Setting up the disctonnect event :
|
|
5154
5155
|
serverSocket.on("endConnection",()=>{
|
|
@@ -5236,7 +5237,7 @@ WebsocketImplementation={
|
|
|
5236
5237
|
|
|
5237
5238
|
|
|
5238
5239
|
// TODO : FIXME : Use one single interface !
|
|
5239
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5240
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
|
|
5240
5241
|
else if(clientSocket.connected) return;
|
|
5241
5242
|
|
|
5242
5243
|
|
|
@@ -5260,7 +5261,7 @@ WebsocketImplementation={
|
|
|
5260
5261
|
|
|
5261
5262
|
// TODO : FIXME : Use one single interface !
|
|
5262
5263
|
let clientSocket=clientSocketParam;
|
|
5263
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5264
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
|
|
5264
5265
|
else if(clientSocket.connected) return;
|
|
5265
5266
|
|
|
5266
5267
|
|
|
@@ -5437,7 +5438,7 @@ WebsocketImplementation={
|
|
|
5437
5438
|
|
|
5438
5439
|
|
|
5439
5440
|
// NEW : ws :
|
|
5440
|
-
if(typeof(WebSocket)==="undefined"){
|
|
5441
|
+
if(typeof(WebsocketImplementation.WebSocket)==="undefined"){
|
|
5441
5442
|
// TRACE
|
|
5442
5443
|
lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
|
|
5443
5444
|
return null;
|
|
@@ -5446,18 +5447,18 @@ WebsocketImplementation={
|
|
|
5446
5447
|
// NODE CLIENT MODE ONLY :
|
|
5447
5448
|
let clientSocket;
|
|
5448
5449
|
if(!WebsocketImplementation.useSocketIOImplementation){
|
|
5449
|
-
clientSocket=new WebSocket(serverURL+":"+port,/*WORKAROUND:*/{ rejectUnauthorized:false, secure: isSecure });
|
|
5450
|
+
clientSocket=new WebsocketImplementation.WebSocket(serverURL+":"+port,/*WORKAROUND:*/{ rejectUnauthorized:false, secure: isSecure });
|
|
5450
5451
|
}else{
|
|
5451
5452
|
// NOW : socket.io :
|
|
5452
5453
|
//client on server-side:
|
|
5453
5454
|
|
|
5454
5455
|
|
|
5455
|
-
if(WebsocketImplementation.isNodeContext && typeof(socketIO)!=="undefined"){
|
|
5456
|
+
if(WebsocketImplementation.isNodeContext && typeof(WebsocketImplementation.socketIO)!=="undefined"){
|
|
5456
5457
|
// // Node client :
|
|
5457
5458
|
// connectToServer=function (serverURL, port, isSecure, timeout=10000){
|
|
5458
|
-
// return socketIO.connect(serverURL + ":" + port,{timeout: timeout});
|
|
5459
|
+
// return WebsocketImplementation.socketIO.connect(serverURL + ":" + port,{timeout: timeout});
|
|
5459
5460
|
// }
|
|
5460
|
-
clientSocket=socketIO.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5461
|
+
clientSocket=WebsocketImplementation.socketIO.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5461
5462
|
}
|
|
5462
5463
|
}
|
|
5463
5464
|
|
|
@@ -5517,7 +5518,7 @@ WebsocketImplementation={
|
|
|
5517
5518
|
// console.log("(NODE CLIENT) TRYING TO SEND : clientSocket.readyState:",clientSocket.readyState);
|
|
5518
5519
|
|
|
5519
5520
|
// TODO : FIXME : Use one single interface !
|
|
5520
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5521
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
|
|
5521
5522
|
else if(clientSocket.connected) return;
|
|
5522
5523
|
|
|
5523
5524
|
|
|
@@ -5594,7 +5595,7 @@ WebsocketImplementation={
|
|
|
5594
5595
|
/*private*/connectToServerFromBrowser:(serverURL, port, isSecure, timeout)=>{
|
|
5595
5596
|
|
|
5596
5597
|
// NEW : ws :
|
|
5597
|
-
if(typeof(WebSocket)==="undefined"){
|
|
5598
|
+
if(typeof(WebsocketImplementation.WebSocket)==="undefined"){
|
|
5598
5599
|
// TRACE
|
|
5599
5600
|
lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
|
|
5600
5601
|
return null;
|
|
@@ -5604,7 +5605,7 @@ WebsocketImplementation={
|
|
|
5604
5605
|
// BROWSER CLIENT MODE ONLY :
|
|
5605
5606
|
let clientSocket;
|
|
5606
5607
|
if(!WebsocketImplementation.useSocketIOImplementation){
|
|
5607
|
-
clientSocket=new WebSocket(serverURL+":"+port,["ws","wss"]);
|
|
5608
|
+
clientSocket=new WebsocketImplementation.WebSocket(serverURL+":"+port,["ws","wss"]);
|
|
5608
5609
|
}else if(typeof(io)!=="undefined"){
|
|
5609
5610
|
// NOW : socket.io :
|
|
5610
5611
|
// // Browser client :
|
|
@@ -5670,7 +5671,7 @@ WebsocketImplementation={
|
|
|
5670
5671
|
// console.log("(BROWSER) TRYING TO SEND : clientSocket.readyState:",clientSocket.readyState);
|
|
5671
5672
|
|
|
5672
5673
|
// TODO : FIXME : Use one single interface !
|
|
5673
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5674
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebsocketImplementation.WebSocket.OPEN) return;
|
|
5674
5675
|
else if(clientSocket.connected) return;
|
|
5675
5676
|
|
|
5676
5677
|
|
aotrautils-srv/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils-srv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.94",
|
|
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)",
|