aotrautils-srv 0.0.102 → 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,14 +5111,14 @@ WebsocketImplementation={
|
|
|
5116
5111
|
|
|
5117
5112
|
// *********************************************************************************
|
|
5118
5113
|
|
|
5119
|
-
|
|
5120
|
-
|
|
5114
|
+
socketIO=require("socket.io");
|
|
5115
|
+
WebSocket=require("ws");
|
|
5121
5116
|
|
|
5122
5117
|
|
|
5123
5118
|
|
|
5124
5119
|
// DBG
|
|
5125
|
-
console.log("IIIII
|
|
5126
|
-
console.log("IIIII
|
|
5120
|
+
console.log("IIIII socketIO:",JSON.stringify(socketIO));
|
|
5121
|
+
console.log("IIIII WebSocket:",JSON.stringify(WebSocket));
|
|
5127
5122
|
|
|
5128
5123
|
|
|
5129
5124
|
|
|
@@ -5144,18 +5139,18 @@ WebsocketImplementation={
|
|
|
5144
5139
|
// NODE SERVER MODE ONLY :
|
|
5145
5140
|
let serverSocket;
|
|
5146
5141
|
if(!WebsocketImplementation.useSocketIOImplementation){
|
|
5147
|
-
serverSocket=new
|
|
5142
|
+
serverSocket=new WebSocket.Server({ "server":listenableServer });
|
|
5148
5143
|
}else{
|
|
5149
5144
|
|
|
5150
5145
|
|
|
5151
5146
|
// DBG
|
|
5152
5147
|
// console.log(">>>>>>>require(socket.io):",JSON.stringify(require("socket.io")));
|
|
5153
|
-
console.log(">>>>>>>
|
|
5154
|
-
console.log(">>>>>>>
|
|
5148
|
+
console.log(">>>>>>>socketIO:",JSON.stringify(socketIO));
|
|
5149
|
+
console.log(">>>>>>>WebSocket:",JSON.stringify(WebSocket));
|
|
5155
5150
|
|
|
5156
5151
|
// NOW : socket.io :
|
|
5157
5152
|
// Loading socket.io
|
|
5158
|
-
serverSocket=
|
|
5153
|
+
serverSocket=socketIO.listen(listenableServer);
|
|
5159
5154
|
|
|
5160
5155
|
// Setting up the disctonnect event :
|
|
5161
5156
|
serverSocket.on("endConnection",()=>{
|
|
@@ -5243,7 +5238,7 @@ WebsocketImplementation={
|
|
|
5243
5238
|
|
|
5244
5239
|
|
|
5245
5240
|
// TODO : FIXME : Use one single interface !
|
|
5246
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==
|
|
5241
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5247
5242
|
else if(clientSocket.connected) return;
|
|
5248
5243
|
|
|
5249
5244
|
|
|
@@ -5267,7 +5262,7 @@ WebsocketImplementation={
|
|
|
5267
5262
|
|
|
5268
5263
|
// TODO : FIXME : Use one single interface !
|
|
5269
5264
|
let clientSocket=clientSocketParam;
|
|
5270
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==
|
|
5265
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5271
5266
|
else if(clientSocket.connected) return;
|
|
5272
5267
|
|
|
5273
5268
|
|
|
@@ -5444,7 +5439,7 @@ WebsocketImplementation={
|
|
|
5444
5439
|
|
|
5445
5440
|
|
|
5446
5441
|
// NEW : ws :
|
|
5447
|
-
if(typeof(
|
|
5442
|
+
if(typeof(WebSocket)==="undefined"){
|
|
5448
5443
|
// TRACE
|
|
5449
5444
|
lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
|
|
5450
5445
|
return null;
|
|
@@ -5453,18 +5448,18 @@ WebsocketImplementation={
|
|
|
5453
5448
|
// NODE CLIENT MODE ONLY :
|
|
5454
5449
|
let clientSocket;
|
|
5455
5450
|
if(!WebsocketImplementation.useSocketIOImplementation){
|
|
5456
|
-
clientSocket=new
|
|
5451
|
+
clientSocket=new WebSocket(serverURL+":"+port,/*WORKAROUND:*/{ rejectUnauthorized:false, secure: isSecure });
|
|
5457
5452
|
}else{
|
|
5458
5453
|
// NOW : socket.io :
|
|
5459
5454
|
//client on server-side:
|
|
5460
5455
|
|
|
5461
5456
|
|
|
5462
|
-
if(WebsocketImplementation.isNodeContext && typeof(
|
|
5457
|
+
if(WebsocketImplementation.isNodeContext && typeof(socketIO)!=="undefined"){
|
|
5463
5458
|
// // Node client :
|
|
5464
5459
|
// connectToServer=function (serverURL, port, isSecure, timeout=10000){
|
|
5465
|
-
// return
|
|
5460
|
+
// return socketIO.connect(serverURL + ":" + port,{timeout: timeout});
|
|
5466
5461
|
// }
|
|
5467
|
-
clientSocket=
|
|
5462
|
+
clientSocket=socketIO.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5468
5463
|
}
|
|
5469
5464
|
}
|
|
5470
5465
|
|
|
@@ -5524,7 +5519,7 @@ WebsocketImplementation={
|
|
|
5524
5519
|
// console.log("(NODE CLIENT) TRYING TO SEND : clientSocket.readyState:",clientSocket.readyState);
|
|
5525
5520
|
|
|
5526
5521
|
// TODO : FIXME : Use one single interface !
|
|
5527
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==
|
|
5522
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5528
5523
|
else if(clientSocket.connected) return;
|
|
5529
5524
|
|
|
5530
5525
|
|
|
@@ -5601,7 +5596,7 @@ WebsocketImplementation={
|
|
|
5601
5596
|
/*private*/connectToServerFromBrowser:(serverURL, port, isSecure, timeout)=>{
|
|
5602
5597
|
|
|
5603
5598
|
// NEW : ws :
|
|
5604
|
-
if(typeof(
|
|
5599
|
+
if(typeof(WebSocket)==="undefined"){
|
|
5605
5600
|
// TRACE
|
|
5606
5601
|
lognow("ERROR : CLIENT : Could not find websocket client lib, aborting client connection.");
|
|
5607
5602
|
return null;
|
|
@@ -5611,7 +5606,7 @@ WebsocketImplementation={
|
|
|
5611
5606
|
// BROWSER CLIENT MODE ONLY :
|
|
5612
5607
|
let clientSocket;
|
|
5613
5608
|
if(!WebsocketImplementation.useSocketIOImplementation){
|
|
5614
|
-
clientSocket=new
|
|
5609
|
+
clientSocket=new WebSocket(serverURL+":"+port,["ws","wss"]);
|
|
5615
5610
|
}else if(typeof(io)!=="undefined"){
|
|
5616
5611
|
// NOW : socket.io :
|
|
5617
5612
|
// // Browser client :
|
|
@@ -5677,7 +5672,7 @@ WebsocketImplementation={
|
|
|
5677
5672
|
// console.log("(BROWSER) TRYING TO SEND : clientSocket.readyState:",clientSocket.readyState);
|
|
5678
5673
|
|
|
5679
5674
|
// TODO : FIXME : Use one single interface !
|
|
5680
|
-
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==
|
|
5675
|
+
if(!WebsocketImplementation.useSocketIOImplementation) if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
5681
5676
|
else if(clientSocket.connected) return;
|
|
5682
5677
|
|
|
5683
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)",
|