aotrautils-srv 0.0.128 → 0.0.131
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-16:
|
|
3
|
+
/*utils COMMONS library associated with aotra version : «1.0.0.000 (16/07/2022-16:48:44)»*/
|
|
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-16:
|
|
4831
|
+
/*utils SERVER library associated with aotra version : «1.0.0.000 (16/07/2022-16:48:44)»*/
|
|
4832
4832
|
/*-----------------------------------------------------------------------------*/
|
|
4833
4833
|
|
|
4834
4834
|
|
|
@@ -4872,10 +4872,8 @@ 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
|
-
//
|
|
4876
|
-
//
|
|
4877
|
-
Socket=require("socket.io");
|
|
4878
|
-
WebSocket=require("ws");
|
|
4875
|
+
//Socket=require("socket.io");
|
|
4876
|
+
//WebSocket=require("ws");
|
|
4879
4877
|
|
|
4880
4878
|
|
|
4881
4879
|
|
|
@@ -5066,21 +5064,46 @@ WebsocketImplementation={
|
|
|
5066
5064
|
getStatic:(isNodeContext=true, useSocketIOImplementation=false)=>{
|
|
5067
5065
|
|
|
5068
5066
|
WebsocketImplementation.isNodeContext=isNodeContext;
|
|
5069
|
-
|
|
5070
5067
|
WebsocketImplementation.useSocketIOImplementation=useSocketIOImplementation;
|
|
5071
5068
|
|
|
5072
5069
|
if(WebsocketImplementation.useSocketIOImplementation){
|
|
5073
5070
|
// TRACE
|
|
5074
5071
|
lognow("INFO : (SERVER/CLIENT) Using socket.io websocket implementation.");
|
|
5072
|
+
|
|
5073
|
+
if(isNodeContext && typeof(Socket)==="undefined"){
|
|
5074
|
+
// TRACE
|
|
5075
|
+
console.log("«socket.io» SERVER library not called yet, calling it now.");
|
|
5076
|
+
Socket=require("socket.io");
|
|
5077
|
+
return WebsocketImplementation;
|
|
5078
|
+
}
|
|
5079
|
+
if(typeof(Socket)==="undefined"){
|
|
5080
|
+
// TRACE
|
|
5081
|
+
console.log("ERROR : «socket.io» CONSOLE/BROWSER CLIENT/SERVER library not found. Cannot launch nodejs server. Aborting.");
|
|
5082
|
+
return WebsocketImplementation;
|
|
5083
|
+
}
|
|
5075
5084
|
|
|
5076
5085
|
}else{
|
|
5077
5086
|
// TRACE
|
|
5078
|
-
lognow("INFO : (SERVER/CLIENT) Using native
|
|
5087
|
+
lognow("INFO : (SERVER/CLIENT) Using native WebSocket implementation.");
|
|
5088
|
+
|
|
5089
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications
|
|
5090
|
+
if(isNodeContext && typeof(WebSocket)==="undefined"){
|
|
5091
|
+
WebSocket=require("ws");
|
|
5092
|
+
// TRACE
|
|
5093
|
+
console.log("«ws» SERVER library not called yet, calling it now.");
|
|
5094
|
+
return WebsocketImplementation;
|
|
5095
|
+
}
|
|
5096
|
+
if(typeof(WebSocket)==="undefined"){
|
|
5097
|
+
// TRACE
|
|
5098
|
+
console.log("ERROR : «ws» CONSOLE/BROWSER CLIENT/SERVER library not found. Cannot launch nodejs server. Aborting.");
|
|
5099
|
+
return WebsocketImplementation;
|
|
5100
|
+
}
|
|
5079
5101
|
|
|
5080
5102
|
}
|
|
5103
|
+
|
|
5081
5104
|
|
|
5082
5105
|
// *********************************************************************************
|
|
5083
|
-
|
|
5106
|
+
|
|
5084
5107
|
|
|
5085
5108
|
return WebsocketImplementation;
|
|
5086
5109
|
},
|
|
@@ -5296,7 +5319,10 @@ WebsocketImplementation={
|
|
|
5296
5319
|
|
|
5297
5320
|
clientSocket.isAlive=false;
|
|
5298
5321
|
try{
|
|
5299
|
-
|
|
5322
|
+
|
|
5323
|
+
if(!WebsocketImplementation.useSocketIOImplementation) clientSocket.ping();
|
|
5324
|
+
else clientSocket.emit("ping");
|
|
5325
|
+
|
|
5300
5326
|
}catch(error){
|
|
5301
5327
|
lognow("ERROR : A problem occurred when tried to ping client socket : ",error);
|
|
5302
5328
|
// We effectively end the client connection to this server :
|
|
@@ -5315,9 +5341,16 @@ WebsocketImplementation={
|
|
|
5315
5341
|
|
|
5316
5342
|
|
|
5317
5343
|
}, nodeServerInstance.clientTimeoutMillis);
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5344
|
+
|
|
5345
|
+
if(!WebsocketImplementation.useSocketIOImplementation){
|
|
5346
|
+
clientSocket.on("pong",()=>{
|
|
5347
|
+
clientSocket.isAlive=true;
|
|
5348
|
+
});
|
|
5349
|
+
}else{
|
|
5350
|
+
clientSocket.on("ping",()=>{
|
|
5351
|
+
clientSocket.isAlive=true;
|
|
5352
|
+
});
|
|
5353
|
+
}
|
|
5321
5354
|
|
|
5322
5355
|
|
|
5323
5356
|
|
|
@@ -5394,7 +5427,6 @@ WebsocketImplementation={
|
|
|
5394
5427
|
/*private*/connectToServerFromNode:(serverURL, port, isSecure, timeout)=>{
|
|
5395
5428
|
|
|
5396
5429
|
|
|
5397
|
-
|
|
5398
5430
|
// NEW : ws :
|
|
5399
5431
|
if(typeof(WebSocket)==="undefined"){
|
|
5400
5432
|
// TRACE
|
|
@@ -5417,7 +5449,8 @@ WebsocketImplementation={
|
|
|
5417
5449
|
// }
|
|
5418
5450
|
|
|
5419
5451
|
// OLD SYNTAX: clientSocket=Socket.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5420
|
-
|
|
5452
|
+
// clientSocket=new Socket.Client???(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5453
|
+
clientSocket=io(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5421
5454
|
|
|
5422
5455
|
}
|
|
5423
5456
|
}
|
|
@@ -5576,7 +5609,9 @@ WebsocketImplementation={
|
|
|
5576
5609
|
// }else{
|
|
5577
5610
|
// // TRACE
|
|
5578
5611
|
// console.log("ERROR : Could not initialize socket !");
|
|
5579
|
-
clientSocket=io.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5612
|
+
// OLD SYNTAX :clientSocket=io.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5613
|
+
clientSocket=io(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5614
|
+
|
|
5580
5615
|
}
|
|
5581
5616
|
|
|
5582
5617
|
|
aotrautils-srv/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils-srv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.131",
|
|
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)",
|