aotrautils-srv 0.0.100 → 0.0.103
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-23:
|
|
3
|
+
/*utils COMMONS library associated with aotra version : «1.0.0.000 (13/07/2022-23:48:03)»*/
|
|
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-23:
|
|
4831
|
+
/*utils SERVER library associated with aotra version : «1.0.0.000 (13/07/2022-23:48:03)»*/
|
|
4832
4832
|
/*-----------------------------------------------------------------------------*/
|
|
4833
4833
|
|
|
4834
4834
|
|
|
@@ -5075,11 +5075,6 @@ if(typeof(fs)==="undefined"){
|
|
|
5075
5075
|
// NODE ONLY SERVER / CLIENTS :
|
|
5076
5076
|
WebsocketImplementation={
|
|
5077
5077
|
|
|
5078
|
-
////
|
|
5079
|
-
|
|
5080
|
-
socketIO:null,
|
|
5081
|
-
WebSocket:null,
|
|
5082
|
-
|
|
5083
5078
|
|
|
5084
5079
|
isNodeContext:true,
|
|
5085
5080
|
useSocketIOImplementation:false,
|
|
@@ -5116,10 +5111,15 @@ WebsocketImplementation={
|
|
|
5116
5111
|
|
|
5117
5112
|
// *********************************************************************************
|
|
5118
5113
|
|
|
5119
|
-
|
|
5120
|
-
|
|
5114
|
+
socketIO=require("socket.io");
|
|
5115
|
+
WebSocket=require("ws");
|
|
5121
5116
|
|
|
5122
5117
|
|
|
5118
|
+
|
|
5119
|
+
// DBG
|
|
5120
|
+
console.log("IIIII socketIO:",JSON.stringify(socketIO));
|
|
5121
|
+
console.log("IIIII WebSocket:",JSON.stringify(WebSocket));
|
|
5122
|
+
|
|
5123
5123
|
|
|
5124
5124
|
|
|
5125
5125
|
return WebsocketImplementation;
|
|
@@ -5139,18 +5139,18 @@ WebsocketImplementation={
|
|
|
5139
5139
|
// NODE SERVER MODE ONLY :
|
|
5140
5140
|
let serverSocket;
|
|
5141
5141
|
if(!WebsocketImplementation.useSocketIOImplementation){
|
|
5142
|
-
serverSocket=new
|
|
5142
|
+
serverSocket=new WebSocket.Server({ "server":listenableServer });
|
|
5143
5143
|
}else{
|
|
5144
5144
|
|
|
5145
5145
|
|
|
5146
5146
|
// DBG
|
|
5147
|
-
console.log(">>>>>>>require(socket.io):",JSON.stringify(require("socket.io")));
|
|
5148
|
-
console.log(">>>>>>>
|
|
5149
|
-
console.log(">>>>>>>
|
|
5147
|
+
// console.log(">>>>>>>require(socket.io):",JSON.stringify(require("socket.io")));
|
|
5148
|
+
console.log(">>>>>>>socketIO:",JSON.stringify(socketIO));
|
|
5149
|
+
console.log(">>>>>>>WebSocket:",JSON.stringify(WebSocket));
|
|
5150
5150
|
|
|
5151
5151
|
// NOW : socket.io :
|
|
5152
5152
|
// Loading socket.io
|
|
5153
|
-
serverSocket=
|
|
5153
|
+
serverSocket=socketIO.listen(listenableServer);
|
|
5154
5154
|
|
|
5155
5155
|
// Setting up the disctonnect event :
|
|
5156
5156
|
serverSocket.on("endConnection",()=>{
|
|
@@ -5238,7 +5238,7 @@ WebsocketImplementation={
|
|
|
5238
5238
|
|
|
5239
5239
|
|
|
5240
5240
|
// TODO : FIXME : Use one single interface !
|
|
5241
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==
|
|
5241
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5242
5242
|
else if(clientSocket.connected) return;
|
|
5243
5243
|
|
|
5244
5244
|
|
|
@@ -5262,7 +5262,7 @@ WebsocketImplementation={
|
|
|
5262
5262
|
|
|
5263
5263
|
// TODO : FIXME : Use one single interface !
|
|
5264
5264
|
let clientSocket=clientSocketParam;
|
|
5265
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==
|
|
5265
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5266
5266
|
else if(clientSocket.connected) return;
|
|
5267
5267
|
|
|
5268
5268
|
|
|
@@ -5439,7 +5439,7 @@ WebsocketImplementation={
|
|
|
5439
5439
|
|
|
5440
5440
|
|
|
5441
5441
|
// NEW : ws :
|
|
5442
|
-
if(typeof(
|
|
5442
|
+
if(typeof(WebSocket)==="undefined"){
|
|
5443
5443
|
// TRACE
|
|
5444
5444
|
lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
|
|
5445
5445
|
return null;
|
|
@@ -5448,18 +5448,18 @@ WebsocketImplementation={
|
|
|
5448
5448
|
// NODE CLIENT MODE ONLY :
|
|
5449
5449
|
let clientSocket;
|
|
5450
5450
|
if(!WebsocketImplementation.useSocketIOImplementation){
|
|
5451
|
-
clientSocket=new
|
|
5451
|
+
clientSocket=new WebSocket(serverURL+":"+port,/*WORKAROUND:*/{ rejectUnauthorized:false, secure: isSecure });
|
|
5452
5452
|
}else{
|
|
5453
5453
|
// NOW : socket.io :
|
|
5454
5454
|
//client on server-side:
|
|
5455
5455
|
|
|
5456
5456
|
|
|
5457
|
-
if(WebsocketImplementation.isNodeContext && typeof(
|
|
5457
|
+
if(WebsocketImplementation.isNodeContext && typeof(socketIO)!=="undefined"){
|
|
5458
5458
|
// // Node client :
|
|
5459
5459
|
// connectToServer=function (serverURL, port, isSecure, timeout=10000){
|
|
5460
|
-
// return
|
|
5460
|
+
// return socketIO.connect(serverURL + ":" + port,{timeout: timeout});
|
|
5461
5461
|
// }
|
|
5462
|
-
clientSocket=
|
|
5462
|
+
clientSocket=socketIO.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5463
5463
|
}
|
|
5464
5464
|
}
|
|
5465
5465
|
|
|
@@ -5519,7 +5519,7 @@ WebsocketImplementation={
|
|
|
5519
5519
|
// console.log("(NODE CLIENT) TRYING TO SEND : clientSocket.readyState:",clientSocket.readyState);
|
|
5520
5520
|
|
|
5521
5521
|
// TODO : FIXME : Use one single interface !
|
|
5522
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==
|
|
5522
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5523
5523
|
else if(clientSocket.connected) return;
|
|
5524
5524
|
|
|
5525
5525
|
|
|
@@ -5596,7 +5596,7 @@ WebsocketImplementation={
|
|
|
5596
5596
|
/*private*/connectToServerFromBrowser:(serverURL, port, isSecure, timeout)=>{
|
|
5597
5597
|
|
|
5598
5598
|
// NEW : ws :
|
|
5599
|
-
if(typeof(
|
|
5599
|
+
if(typeof(WebSocket)==="undefined"){
|
|
5600
5600
|
// TRACE
|
|
5601
5601
|
lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
|
|
5602
5602
|
return null;
|
|
@@ -5606,7 +5606,7 @@ WebsocketImplementation={
|
|
|
5606
5606
|
// BROWSER CLIENT MODE ONLY :
|
|
5607
5607
|
let clientSocket;
|
|
5608
5608
|
if(!WebsocketImplementation.useSocketIOImplementation){
|
|
5609
|
-
clientSocket=new
|
|
5609
|
+
clientSocket=new WebSocket(serverURL+":"+port,["ws","wss"]);
|
|
5610
5610
|
}else if(typeof(io)!=="undefined"){
|
|
5611
5611
|
// NOW : socket.io :
|
|
5612
5612
|
// // Browser client :
|
|
@@ -5672,7 +5672,7 @@ WebsocketImplementation={
|
|
|
5672
5672
|
// console.log("(BROWSER) TRYING TO SEND : clientSocket.readyState:",clientSocket.readyState);
|
|
5673
5673
|
|
|
5674
5674
|
// TODO : FIXME : Use one single interface !
|
|
5675
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==
|
|
5675
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5676
5676
|
else if(clientSocket.connected) return;
|
|
5677
5677
|
|
|
5678
5678
|
|
aotrautils-srv/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils-srv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.103",
|
|
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)",
|