aotrautils-srv 0.0.127 → 0.0.130
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:41:40)»*/
|
|
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:41:40)»*/
|
|
4832
4832
|
/*-----------------------------------------------------------------------------*/
|
|
4833
4833
|
|
|
4834
4834
|
|
|
@@ -4872,17 +4872,11 @@ 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
|
|
|
4882
|
-
// DBG
|
|
4883
|
-
console.log("Socket!!!!!!>>>>",Socket);
|
|
4884
|
-
console.log("WebSocket!!!!!!>>>>",WebSocket);
|
|
4885
|
-
|
|
4886
4880
|
|
|
4887
4881
|
// =================================================================================
|
|
4888
4882
|
// NODEJS UTILS
|
|
@@ -5052,10 +5046,8 @@ if(typeof(fs)==="undefined"){
|
|
|
5052
5046
|
|
|
5053
5047
|
// NODE ONLY SERVER / CLIENTS :
|
|
5054
5048
|
WebsocketImplementation={
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
// WebSocket:WebSocket,
|
|
5058
|
-
|
|
5049
|
+
|
|
5050
|
+
|
|
5059
5051
|
isNodeContext:true,
|
|
5060
5052
|
useSocketIOImplementation:false,
|
|
5061
5053
|
useFlatStrings:false,
|
|
@@ -5072,26 +5064,46 @@ WebsocketImplementation={
|
|
|
5072
5064
|
getStatic:(isNodeContext=true, useSocketIOImplementation=false)=>{
|
|
5073
5065
|
|
|
5074
5066
|
WebsocketImplementation.isNodeContext=isNodeContext;
|
|
5075
|
-
|
|
5076
5067
|
WebsocketImplementation.useSocketIOImplementation=useSocketIOImplementation;
|
|
5077
5068
|
|
|
5078
5069
|
if(WebsocketImplementation.useSocketIOImplementation){
|
|
5079
5070
|
// TRACE
|
|
5080
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
|
+
}
|
|
5081
5084
|
|
|
5082
5085
|
}else{
|
|
5083
5086
|
// TRACE
|
|
5084
|
-
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
|
+
}
|
|
5085
5101
|
|
|
5086
5102
|
}
|
|
5103
|
+
|
|
5087
5104
|
|
|
5088
5105
|
// *********************************************************************************
|
|
5089
|
-
|
|
5090
|
-
// DBG
|
|
5091
|
-
console.log("11111 Socket:",Socket);
|
|
5092
|
-
console.log("11111 WebSocket:",WebSocket);
|
|
5093
5106
|
|
|
5094
|
-
|
|
5095
5107
|
|
|
5096
5108
|
return WebsocketImplementation;
|
|
5097
5109
|
},
|
|
@@ -5113,10 +5125,6 @@ WebsocketImplementation={
|
|
|
5113
5125
|
serverSocket=new WebSocket.Server({ "server":listenableServer });
|
|
5114
5126
|
}else{
|
|
5115
5127
|
|
|
5116
|
-
|
|
5117
|
-
// DBG
|
|
5118
|
-
console.log(">>>>>>>Socket:",Socket);
|
|
5119
|
-
console.log(">>>>>>>WebSocket:",WebSocket);
|
|
5120
5128
|
|
|
5121
5129
|
// NOW : socket.io :
|
|
5122
5130
|
// Loading socket.io
|
|
@@ -5409,7 +5417,6 @@ WebsocketImplementation={
|
|
|
5409
5417
|
/*private*/connectToServerFromNode:(serverURL, port, isSecure, timeout)=>{
|
|
5410
5418
|
|
|
5411
5419
|
|
|
5412
|
-
|
|
5413
5420
|
// NEW : ws :
|
|
5414
5421
|
if(typeof(WebSocket)==="undefined"){
|
|
5415
5422
|
// TRACE
|
|
@@ -5432,7 +5439,8 @@ WebsocketImplementation={
|
|
|
5432
5439
|
// }
|
|
5433
5440
|
|
|
5434
5441
|
// OLD SYNTAX: clientSocket=Socket.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5435
|
-
|
|
5442
|
+
// clientSocket=new Socket.Client???(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5443
|
+
clientSocket=io(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5436
5444
|
|
|
5437
5445
|
}
|
|
5438
5446
|
}
|
|
@@ -5591,7 +5599,9 @@ WebsocketImplementation={
|
|
|
5591
5599
|
// }else{
|
|
5592
5600
|
// // TRACE
|
|
5593
5601
|
// console.log("ERROR : Could not initialize socket !");
|
|
5594
|
-
clientSocket=io.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5602
|
+
// OLD SYNTAX :clientSocket=io.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5603
|
+
clientSocket=io(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
5604
|
+
|
|
5595
5605
|
}
|
|
5596
5606
|
|
|
5597
5607
|
|
aotrautils-srv/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils-srv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.130",
|
|
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)",
|