aotrautils-srv 0.0.1888 → 0.0.1891
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.
- aotrautils-srv/aotrautils-srv.build.js +289 -164
- aotrautils-srv/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (
|
|
3
|
+
/*utils COMMONS library associated with aotra version : «1_29072022-2359 (25/07/2026-22:02:26)»*/
|
|
4
4
|
/*-----------------------------------------------------------------------------*/
|
|
5
5
|
|
|
6
6
|
|
|
@@ -5470,7 +5470,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
|
|
|
5470
5470
|
|
|
5471
5471
|
|
|
5472
5472
|
|
|
5473
|
-
/*utils AI library associated with aotra version : «1_29072022-2359 (
|
|
5473
|
+
/*utils AI library associated with aotra version : «1_29072022-2359 (25/07/2026-22:02:26)»*/
|
|
5474
5474
|
/*-----------------------------------------------------------------------------*/
|
|
5475
5475
|
|
|
5476
5476
|
|
|
@@ -5730,7 +5730,7 @@ getLLMAPIClient=(modelName, apiURL, agentRole, defaultPrompt, llmProviderName=DE
|
|
|
5730
5730
|
|
|
5731
5731
|
|
|
5732
5732
|
|
|
5733
|
-
/*utils CONSOLE library associated with aotra version : «1_29072022-2359 (
|
|
5733
|
+
/*utils CONSOLE library associated with aotra version : «1_29072022-2359 (25/07/2026-22:02:26)»*/
|
|
5734
5734
|
/*-----------------------------------------------------------------------------*/
|
|
5735
5735
|
|
|
5736
5736
|
|
|
@@ -5773,7 +5773,7 @@ if(typeof(window)==="undefined") window=global;
|
|
|
5773
5773
|
|
|
5774
5774
|
class AORTACClientCell{
|
|
5775
5775
|
|
|
5776
|
-
constructor(serverCellOrigin, model, view, isNodeContext=
|
|
5776
|
+
constructor(serverCellOrigin, model, view, isNodeContext=true){
|
|
5777
5777
|
|
|
5778
5778
|
this.clientId=getUUID();
|
|
5779
5779
|
|
|
@@ -5816,7 +5816,9 @@ class AORTACClientCell{
|
|
|
5816
5816
|
|
|
5817
5817
|
|
|
5818
5818
|
// 1) Initial connection
|
|
5819
|
-
self.initialClientInstance=initClient(self.isNodeContext
|
|
5819
|
+
self.initialClientInstance=initClient(self.isNodeContext
|
|
5820
|
+
// ,false
|
|
5821
|
+
,(socketToServerClientInstance, initialClientInstanceLocal)=>{
|
|
5820
5822
|
|
|
5821
5823
|
// DBG
|
|
5822
5824
|
lognow("DEBUG : Starting client...");
|
|
@@ -5910,7 +5912,9 @@ class AORTACClientCell{
|
|
|
5910
5912
|
const host=nonull(infos.host,"localhost");
|
|
5911
5913
|
const port=nonull(infos.port,"30000");
|
|
5912
5914
|
|
|
5913
|
-
const reconnectedClientInstance=initClient(self.isNodeContext
|
|
5915
|
+
const reconnectedClientInstance=initClient(self.isNodeContext
|
|
5916
|
+
// ,false
|
|
5917
|
+
,(socketToServerClientInstance, reconnectedClientInstanceLocal)=>{
|
|
5914
5918
|
|
|
5915
5919
|
// DBG
|
|
5916
5920
|
lognow("DEBUG : Starting reconnected client...");
|
|
@@ -6092,7 +6096,7 @@ class ClientLobule{
|
|
|
6092
6096
|
|
|
6093
6097
|
|
|
6094
6098
|
|
|
6095
|
-
window.getAORTACClient=function(serverCellOrigin="ws://127.0.0.1:40000", model, view, isNodeContext=
|
|
6099
|
+
window.getAORTACClient=function(serverCellOrigin="ws://127.0.0.1:40000", model, view, isNodeContext=true){
|
|
6096
6100
|
if(nothing(serverCellOrigin)){
|
|
6097
6101
|
// TRACE
|
|
6098
6102
|
lognow("ERROR : No known server node, cannot connect to servers cells blob. Aborting AORTAC client setup.");
|
|
@@ -6307,7 +6311,9 @@ class AORTACServerCell{
|
|
|
6307
6311
|
const outcomingCellHost=nonull(infos.host,"localhost");
|
|
6308
6312
|
const outcomingCellPort=nonull(infos.port,"40000");
|
|
6309
6313
|
|
|
6310
|
-
const clientInstance=initClient(true
|
|
6314
|
+
const clientInstance=initClient(true
|
|
6315
|
+
// ,false
|
|
6316
|
+
,(socketToServerClientInstance)=>{
|
|
6311
6317
|
|
|
6312
6318
|
|
|
6313
6319
|
const channelsNames=[];
|
|
@@ -7845,9 +7851,11 @@ window.fileExists=(filePath)=>{
|
|
|
7845
7851
|
//- WEBSOCKETS AND NODEJS :
|
|
7846
7852
|
|
|
7847
7853
|
function isConnected(clientSocket){
|
|
7848
|
-
if(!WebsocketImplementation.useSocketIOImplementation)
|
|
7849
|
-
|
|
7850
|
-
|
|
7854
|
+
// if(!WebsocketImplementation.useSocketIOImplementation)
|
|
7855
|
+
if(!WebsocketImplementation.implementationToUse)
|
|
7856
|
+
return (clientSocket.readyState===WebSocket.OPEN)
|
|
7857
|
+
return WebsocketImplementation.implementationToUse.isConnected(clientSocket);
|
|
7858
|
+
// return (clientSocket.connected);
|
|
7851
7859
|
}
|
|
7852
7860
|
|
|
7853
7861
|
// Client-side or Server-side :
|
|
@@ -7984,7 +7992,8 @@ WebsocketImplementation={
|
|
|
7984
7992
|
|
|
7985
7993
|
|
|
7986
7994
|
isNodeContext:true,
|
|
7987
|
-
|
|
7995
|
+
// useSocketIOImplementation:false,
|
|
7996
|
+
implementationToUse:null,// null is default (WebSocket)
|
|
7988
7997
|
useFlatStrings:false,
|
|
7989
7998
|
|
|
7990
7999
|
// COMMON METHODS
|
|
@@ -7996,12 +8005,16 @@ WebsocketImplementation={
|
|
|
7996
8005
|
//
|
|
7997
8006
|
// CONSOLE NODE SERVER/CLIENT
|
|
7998
8007
|
//
|
|
7999
|
-
getStatic:(isNodeContext=true
|
|
8008
|
+
getStatic:(isNodeContext=true
|
|
8009
|
+
// , useSocketIOImplementation=/*DEBUG*/false
|
|
8010
|
+
)=>{
|
|
8000
8011
|
|
|
8001
8012
|
WebsocketImplementation.isNodeContext=isNodeContext;
|
|
8002
|
-
|
|
8013
|
+
// WebsocketImplementation.useSocketIOImplementation=useSocketIOImplementation;
|
|
8014
|
+
|
|
8015
|
+
// if(!WebsocketImplementation.useSocketIOImplementation){
|
|
8016
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
8003
8017
|
|
|
8004
|
-
if(!WebsocketImplementation.useSocketIOImplementation){
|
|
8005
8018
|
// TRACE
|
|
8006
8019
|
lognow("INFO : (SERVER/CLIENT) Using native WebSocket implementation.");
|
|
8007
8020
|
|
|
@@ -8021,40 +8034,40 @@ WebsocketImplementation={
|
|
|
8021
8034
|
}
|
|
8022
8035
|
|
|
8023
8036
|
}else{
|
|
8024
|
-
|
|
8025
|
-
lognow("INFO : (SERVER/CLIENT) Using socket.io websocket implementation.");
|
|
8026
|
-
|
|
8027
|
-
if(isNodeContext){
|
|
8028
|
-
|
|
8029
|
-
// NODE SERVER :
|
|
8030
|
-
// DBG
|
|
8031
|
-
lognow("INFO : Loading NODE SERVER socket.io libraries.")
|
|
8032
|
-
if(typeof(Socket)==="undefined"){
|
|
8033
|
-
// TRACE
|
|
8034
|
-
console.log("«socket.io» NODE SERVER library not called yet, calling it now.");
|
|
8035
|
-
Socket=require("socket.io");
|
|
8036
|
-
}
|
|
8037
|
-
if(typeof(Socket)==="undefined"){
|
|
8038
|
-
// TRACE
|
|
8039
|
-
console.log("ERROR : «socket.io» NODE CLIENT/SERVER library not found. Cannot launch nodejs server. Aborting.");
|
|
8040
|
-
}
|
|
8041
|
-
|
|
8042
|
-
// NODE CLIENT :
|
|
8043
|
-
// DBG
|
|
8044
|
-
lognow("INFO : Loading NODE CLIENT socket.io libraries.")
|
|
8045
|
-
if(typeof(io)==="undefined"){
|
|
8046
|
-
// TRACE
|
|
8047
|
-
console.log("«socket.io-client» NODE CLIENT library not called yet, calling it now.");
|
|
8048
|
-
io=require("socket.io-client");
|
|
8049
|
-
}
|
|
8050
|
-
if(typeof(io)==="undefined"){
|
|
8051
|
-
// TRACE
|
|
8052
|
-
console.log("ERROR : «socket-client.io» NODE CLIENT library not found. Cannot launch nodejs server. Aborting.");
|
|
8053
|
-
}
|
|
8054
|
-
}
|
|
8055
|
-
|
|
8056
|
-
|
|
8037
|
+
window.WebSocket=WebsocketImplementation.implementationToUse.getSocketClass();
|
|
8057
8038
|
}
|
|
8039
|
+
// // TRACE
|
|
8040
|
+
// lognow("INFO : (SERVER/CLIENT) Using socket.io websocket implementation.");
|
|
8041
|
+
//
|
|
8042
|
+
// if(isNodeContext){
|
|
8043
|
+
//
|
|
8044
|
+
// // NODE SERVER :
|
|
8045
|
+
// // DBG
|
|
8046
|
+
// lognow("INFO : Loading NODE SERVER socket.io libraries.")
|
|
8047
|
+
// if(typeof(Socket)==="undefined"){
|
|
8048
|
+
// // TRACE
|
|
8049
|
+
// console.log("«socket.io» NODE SERVER library not called yet, calling it now.");
|
|
8050
|
+
// Socket=require("socket.io");
|
|
8051
|
+
// }
|
|
8052
|
+
// if(typeof(Socket)==="undefined"){
|
|
8053
|
+
// // TRACE
|
|
8054
|
+
// console.log("ERROR : «socket.io» NODE CLIENT/SERVER library not found. Cannot launch nodejs server. Aborting.");
|
|
8055
|
+
// }
|
|
8056
|
+
//
|
|
8057
|
+
// // NODE CLIENT :
|
|
8058
|
+
// // DBG
|
|
8059
|
+
// lognow("INFO : Loading NODE CLIENT socket.io libraries.")
|
|
8060
|
+
// if(typeof(io)==="undefined"){
|
|
8061
|
+
// // TRACE
|
|
8062
|
+
// console.log("«socket.io-client» NODE CLIENT library not called yet, calling it now.");
|
|
8063
|
+
// io=require("socket.io-client");
|
|
8064
|
+
// }
|
|
8065
|
+
// if(typeof(io)==="undefined"){
|
|
8066
|
+
// // TRACE
|
|
8067
|
+
// console.log("ERROR : «socket-client.io» NODE CLIENT library not found. Cannot launch nodejs server. Aborting.");
|
|
8068
|
+
// }
|
|
8069
|
+
// }
|
|
8070
|
+
// }
|
|
8058
8071
|
|
|
8059
8072
|
// *********************************************************************************
|
|
8060
8073
|
|
|
@@ -8064,8 +8077,12 @@ WebsocketImplementation={
|
|
|
8064
8077
|
|
|
8065
8078
|
/*public*//*static*/getMessageDataBothImplementations:(eventOrMessageParam)=>{
|
|
8066
8079
|
|
|
8067
|
-
|
|
8068
|
-
|
|
8080
|
+
// const eventOrMessage=(!WebsocketImplementation.useSocketIOImplementation?eventOrMessageParam.data:eventOrMessageParam);
|
|
8081
|
+
const eventOrMessage=
|
|
8082
|
+
(!WebsocketImplementation.implementationToUse)?
|
|
8083
|
+
eventOrMessageParam.data
|
|
8084
|
+
:WebsocketImplementation.implementationToUse.getData(eventOrMessageParam);
|
|
8085
|
+
|
|
8069
8086
|
let dataResult=eventOrMessage;
|
|
8070
8087
|
|
|
8071
8088
|
try{
|
|
@@ -8087,42 +8104,43 @@ WebsocketImplementation={
|
|
|
8087
8104
|
throw new Error("ERROR : SERVER : Server launch is not supported in a non-nodejs context for any implementation.");
|
|
8088
8105
|
}
|
|
8089
8106
|
|
|
8090
|
-
|
|
8091
|
-
// TODO : FIXME : Use one single interface !
|
|
8092
8107
|
// NODE SERVER MODE ONLY :
|
|
8093
8108
|
let serverSocket;
|
|
8094
|
-
|
|
8095
|
-
|
|
8109
|
+
// if(!WebsocketImplementation.useSocketIOImplementation){
|
|
8110
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
8096
8111
|
if(typeof(WebSocketServer)==="undefined")
|
|
8097
8112
|
window.WebSocketServer=require("ws");
|
|
8098
8113
|
if(typeof(WebSocketServer)==="undefined")
|
|
8099
8114
|
// TRACE
|
|
8100
8115
|
lognow("ERROR : «ws» CONSOLE SERVER library not found. Cannot launch nodejs server. Aborting.");
|
|
8101
8116
|
|
|
8102
|
-
// DOES NOT WORK ANYMORE :
|
|
8117
|
+
// DOES NOT WORK ANYMORE : (< node v20)
|
|
8103
8118
|
// serverSocket=new WebSocket.Server({
|
|
8119
|
+
// DOES WORK NOW : (> node v20)
|
|
8104
8120
|
serverSocket=new WebSocketServer.Server({
|
|
8121
|
+
// DOES WORK ALSO : (> node v20)
|
|
8105
8122
|
// serverSocket=new window.WebSocketServer.WebSocketServer({
|
|
8106
8123
|
server:listenableServer,
|
|
8107
|
-
perMessageDeflate: false,
|
|
8124
|
+
perMessageDeflate: false, // (to improve a bit the security)
|
|
8108
8125
|
});
|
|
8109
8126
|
|
|
8110
8127
|
}else{
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
//
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8128
|
+
serverSocket=WebsocketImplementation.implementationToUse.getServerSocket(listenableServer);
|
|
8129
|
+
|
|
8130
|
+
//
|
|
8131
|
+
// // Loading socket.io
|
|
8132
|
+
//// OLD SYNTAX : serverSocket=Socket.listen(listenableServer);
|
|
8133
|
+
// serverSocket=new Socket.Server(listenableServer);
|
|
8134
|
+
//
|
|
8135
|
+
// if(listenableServer.cert || listenableServer.key){
|
|
8136
|
+
// // TRACE :
|
|
8137
|
+
// lognow("WARN : CAUTION ! ON TODAY (01/08/2022) socket.io SERVER LIBRARY IS BOGUS AND WON'T WORK (node clients can't connect !!) IF listenableServer IS A https SERVER !!!");
|
|
8138
|
+
// }
|
|
8139
|
+
//
|
|
8140
|
+
// // Setting up the disconnect event for a client :
|
|
8141
|
+
// serverSocket.on("endConnection",()=>{
|
|
8142
|
+
// serverSocket.disconnect();
|
|
8143
|
+
// });
|
|
8126
8144
|
}
|
|
8127
8145
|
|
|
8128
8146
|
serverSocket.on("error",(error)=>{
|
|
@@ -8142,10 +8160,13 @@ WebsocketImplementation={
|
|
|
8142
8160
|
// To make the server aware of the clients connections states :
|
|
8143
8161
|
nodeServerInstance.serverSocket.on("close", function close() {
|
|
8144
8162
|
|
|
8145
|
-
|
|
8146
|
-
if(!WebsocketImplementation.
|
|
8147
|
-
|
|
8148
|
-
else
|
|
8163
|
+
// if(!WebsocketImplementation.useSocketIOImplementation)
|
|
8164
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
8165
|
+
serverClients=nodeServerInstance.serverSocket.clients;
|
|
8166
|
+
}else{
|
|
8167
|
+
serverClients=WebsocketImplementation.implementationToUse.getClientSockets();
|
|
8168
|
+
// serverClients=nodeServerInstance.serverSocket.sockets.sockets;
|
|
8169
|
+
}
|
|
8149
8170
|
|
|
8150
8171
|
serverClients.forEach((clientSocket)=>{
|
|
8151
8172
|
clearInterval(clientSocket.stateCheckInterval);
|
|
@@ -8176,8 +8197,9 @@ WebsocketImplementation={
|
|
|
8176
8197
|
|
|
8177
8198
|
// NODE CLIENT MODE ONLY :
|
|
8178
8199
|
let clientSocket;
|
|
8179
|
-
|
|
8180
|
-
|
|
8200
|
+
// if(!WebsocketImplementation.useSocketIOImplementation){
|
|
8201
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
8202
|
+
|
|
8181
8203
|
// NEW : ws :
|
|
8182
8204
|
if(typeof(WebSocket)==="undefined"){
|
|
8183
8205
|
// TRACE
|
|
@@ -8188,7 +8210,6 @@ WebsocketImplementation={
|
|
|
8188
8210
|
// TRACE
|
|
8189
8211
|
lognow("INFO : CLIENT : Trying to establish connection to server (serverURL:«"+serverURL+"» ; port:«"+port+"» ; isSecure:«"+isSecure+"»)");
|
|
8190
8212
|
|
|
8191
|
-
|
|
8192
8213
|
clientSocket=new WebSocket(serverURL+":"+port,/*WORKAROUND:*/{
|
|
8193
8214
|
// CAUTION : SECURITY BREACH :
|
|
8194
8215
|
// BUT ALSO NECESSARY TO ALLOW SELF-SIGNED CERTIFICATES USAGE WITH THE YESBOT SYSTEM ON DEV ENVIRONMENTS !
|
|
@@ -8197,28 +8218,30 @@ WebsocketImplementation={
|
|
|
8197
8218
|
secure: isSecure
|
|
8198
8219
|
});
|
|
8199
8220
|
|
|
8221
|
+
// TODO : FIXME :
|
|
8222
|
+
// !!! CAUTION !!! ON TODAY (06/2026) IT DOES NOT WORK ON NODE VERSIONS > v20 !!!
|
|
8223
|
+
// MEANING IT WILL TRIGGER THE error EVENT FOR NO REASON WITH wss:// !!!
|
|
8200
8224
|
clientSocket.addEventListener("error", error=>{
|
|
8201
8225
|
// TRACE
|
|
8202
8226
|
lognow("ERROR : (NODEJS) A WebSocket client error occurred while trying to connect to server: error:", error);
|
|
8203
8227
|
});
|
|
8204
8228
|
|
|
8205
8229
|
}else{
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
clientSocket=io(serverURL + ":" + port,{timeout: timeout, secure: isSecure, autoConnect:true});
|
|
8214
|
-
// UNUSEFUL (since we have the autoconnect:true option) : clientSocket.connect();
|
|
8215
|
-
|
|
8216
|
-
clientSocket.on("connect_error", error=>{
|
|
8217
|
-
// TRACE
|
|
8218
|
-
lognow("ERROR : (NODEJS) A SocketIO client error occurred while trying to connect to server:", error.message);
|
|
8219
|
-
});
|
|
8220
|
-
|
|
8221
|
-
}
|
|
8230
|
+
clientSocket=WebsocketImplementation.implementationToUse.getClientSocket(true);
|
|
8231
|
+
|
|
8232
|
+
// // NOW : socket.io :
|
|
8233
|
+
// //client on server-side:
|
|
8234
|
+
// if(WebsocketImplementation.isNodeContext && typeof(io)!=="undefined"){
|
|
8235
|
+
//// OLD SYNTAX: clientSocket=Socket.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
8236
|
+
//// NO : clientSocket=new Socket.Client(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
8237
|
+
// clientSocket=io(serverURL + ":" + port,{timeout: timeout, secure: isSecure, autoConnect:true});
|
|
8238
|
+
// // UNUSEFUL (since we have the autoconnect:true option) : clientSocket.connect();
|
|
8239
|
+
//
|
|
8240
|
+
// clientSocket.on("connect_error", error=>{
|
|
8241
|
+
// // TRACE
|
|
8242
|
+
// lognow("ERROR : (NODEJS) A SocketIO client error occurred while trying to connect to server:", error.message);
|
|
8243
|
+
// });
|
|
8244
|
+
// }
|
|
8222
8245
|
}
|
|
8223
8246
|
|
|
8224
8247
|
// DBG
|
|
@@ -8241,10 +8264,12 @@ WebsocketImplementation={
|
|
|
8241
8264
|
return null;
|
|
8242
8265
|
}
|
|
8243
8266
|
|
|
8244
|
-
// TODO : FIXME : Use one single interface !
|
|
8245
8267
|
// BROWSER CLIENT MODE ONLY :
|
|
8246
8268
|
let clientSocket;
|
|
8247
|
-
|
|
8269
|
+
|
|
8270
|
+
// if(!WebsocketImplementation.useSocketIOImplementation){
|
|
8271
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
8272
|
+
|
|
8248
8273
|
// CAUTION : PARAMETER rejectUnauthorized:false WILL DO NOTHING,
|
|
8249
8274
|
// BECAUSE THIS IS COMPLETLY HANDLED BY THE BROWSER SECURITY POLICY !
|
|
8250
8275
|
// SO TO CLEAR THE SSL ERROR :
|
|
@@ -8256,17 +8281,17 @@ WebsocketImplementation={
|
|
|
8256
8281
|
// TRACE
|
|
8257
8282
|
lognow("ERROR : (BROWSER) A WebSocket client error occurred while trying to connect to server:", error.message);
|
|
8258
8283
|
});
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8284
|
+
}else{
|
|
8285
|
+
// }else if(typeof(io)!=="undefined"){
|
|
8286
|
+
WebsocketImplementation.implementationToUse.getClientSocket();
|
|
8287
|
+
// // OLD SYNTAX :clientSocket=io.connect(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
8288
|
+
// // ALTERNATIVE :
|
|
8289
|
+
// clientSocket=io(serverURL + ":" + port,{timeout: timeout, secure: isSecure});
|
|
8290
|
+
//
|
|
8291
|
+
// clientSocket.on("connect_error", error=>{
|
|
8292
|
+
// // TRACE
|
|
8293
|
+
// lognow("ERROR : (BROWSER) A SocketIO client error occurred while trying to connect to server:", error.message);
|
|
8294
|
+
// });
|
|
8270
8295
|
}
|
|
8271
8296
|
|
|
8272
8297
|
// BROWSER CLIENT INSTANCE :
|
|
@@ -9067,12 +9092,59 @@ if(typeof(window)==="undefined") window=global;
|
|
|
9067
9092
|
// ==================================================================================================================
|
|
9068
9093
|
|
|
9069
9094
|
|
|
9095
|
+
// TODO : FIXME : DEVELOP...
|
|
9096
|
+
// THIS IS HOW A implementationToUse FOR WEBSOCKET TECHNOLOGY MUST BE :
|
|
9097
|
+
//
|
|
9098
|
+
//return WebsocketImplementation.implementationToUse.isConnected(clientSocket);
|
|
9099
|
+
//
|
|
9100
|
+
//return WebsocketImplementation.implementationToUse.getSocketClass();
|
|
9101
|
+
//
|
|
9102
|
+
//return WebsocketImplementation.implementationToUse.getData(eventOrMessageParam)
|
|
9103
|
+
// serverSocket=WebsocketImplementation.implementationToUse.getServerSocket(listenableServer);
|
|
9104
|
+
//
|
|
9105
|
+
//serverClients=WebsocketImplementation.implementationToUse.getClientSockets();
|
|
9106
|
+
//
|
|
9107
|
+
//clientSocket=WebsocketImplementation.implementationToUse.getClientSocket(isNodeContext=true);
|
|
9108
|
+
//
|
|
9109
|
+
//WebsocketImplementation.implementationToUse.send(dataWrapped);
|
|
9110
|
+
//WebsocketImplementation.implementationToUse.serverSend(clientSocket, dataWrapped);
|
|
9111
|
+
//
|
|
9112
|
+
//WebsocketImplementation.implementationToUse.receive((eventOrMessage)=>{ });
|
|
9113
|
+
//
|
|
9114
|
+
//
|
|
9115
|
+
//WebsocketImplementation.implementationToUse.initClientSocket(clientSocket);
|
|
9116
|
+
//WebsocketImplementation.implementationToUse.initOnClose(()=>{
|
|
9117
|
+
// foreach(self.onServerLostListeners,l=>{l.execute(self.clientSocket);});
|
|
9118
|
+
//});
|
|
9119
|
+
//
|
|
9120
|
+
//WebsocketImplementation.implementationToUse.initOnReceiveBrowserContext(channelNameParam, (eventOrMessage)=>{ });
|
|
9121
|
+
//
|
|
9122
|
+
//WebsocketImplementation.implementationToUse.initOnReceiveNodeContext(channelNameParam, serverReceptionEntryPoint);
|
|
9123
|
+
//
|
|
9124
|
+
//WebsocketImplementation.implementationToUse.getServerClients();
|
|
9125
|
+
//
|
|
9126
|
+
//if(WebsocketImplementation.implementationToUse.isReady(clientSocket)) return;
|
|
9127
|
+
// WebsocketImplementation.implementationToUse.initOnMessageReceived(doOnMessage);
|
|
9128
|
+
// WebsocketImplementation.implementationToUse.terminate();
|
|
9129
|
+
//
|
|
9130
|
+
//WebsocketImplementation.implementationToUse.ping();
|
|
9131
|
+
//
|
|
9132
|
+
//WebsocketImplementation.implementationToUse.doOnPong(()=>{
|
|
9133
|
+
// clientSocket.isConnectionAlive=true;
|
|
9134
|
+
//});
|
|
9135
|
+
|
|
9136
|
+
|
|
9137
|
+
|
|
9138
|
+
|
|
9139
|
+
// ==================================================================================================================
|
|
9070
9140
|
|
|
9071
9141
|
|
|
9072
9142
|
// -Client :
|
|
9073
9143
|
|
|
9074
9144
|
// TODO : Use everywhere it's applicable !
|
|
9075
|
-
initClient=function(isNodeContext=true
|
|
9145
|
+
initClient=function(isNodeContext=true
|
|
9146
|
+
// ,useSocketIOImplementation=/*DEBUG*/false
|
|
9147
|
+
,doOnServerConnection=null, url, /*OPTIONAL*/port=25000, /*OPTIONAL*/timeout=10000, /*OPTIONAL*/selfParam=null){
|
|
9076
9148
|
|
|
9077
9149
|
const isSecure=(contains(url.toLowerCase(),"https:") || contains(url.toLowerCase(),"wss:"));
|
|
9078
9150
|
|
|
@@ -9084,7 +9156,9 @@ initClient=function(isNodeContext=true, useSocketIOImplementation=/*DEBUG*/false
|
|
|
9084
9156
|
// DBG
|
|
9085
9157
|
lognow("INFO : Setting up client :... (url:«"+url+"» ; port:«"+port+"»)");
|
|
9086
9158
|
|
|
9087
|
-
let socketToServerClientInstance=WebsocketImplementation.getStatic(isNodeContext
|
|
9159
|
+
let socketToServerClientInstance=WebsocketImplementation.getStatic(isNodeContext
|
|
9160
|
+
// , useSocketIOImplementation
|
|
9161
|
+
).connectToServer(url, port, isSecure, timeout);
|
|
9088
9162
|
if(!socketToServerClientInstance){
|
|
9089
9163
|
// TRACE
|
|
9090
9164
|
lognow("ERROR : CLIENT : Could not get socketToServerClientInstance, aborting client connection.");
|
|
@@ -9299,12 +9373,16 @@ class ClientInstance{
|
|
|
9299
9373
|
this.clientReceptionEntryPoints.push(clientReceptionEntryPoint);
|
|
9300
9374
|
}
|
|
9301
9375
|
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
|
|
9376
|
+
// // FOR THE SOCKETIO IMPLEMENTATION :
|
|
9377
|
+
// const clientSocket=this.clientSocket;
|
|
9378
|
+
// if(WebsocketImplementation.useSocketIOImplementation){
|
|
9379
|
+
if(WebsocketImplementation.implementationToUse){
|
|
9380
|
+
WebsocketImplementation.implementationToUse.initOnReceiveBrowserContext(channelNameParam, (eventOrMessage)=>{
|
|
9306
9381
|
clientReceptionEntryPoint.execute(eventOrMessage, clientSocket, this.clientReceptionEntryPoints);
|
|
9307
9382
|
});
|
|
9383
|
+
// clientSocket.on(channelNameParam, (eventOrMessage)=>{
|
|
9384
|
+
// clientReceptionEntryPoint.execute(eventOrMessage, clientSocket, this.clientReceptionEntryPoints);
|
|
9385
|
+
// });
|
|
9308
9386
|
}
|
|
9309
9387
|
|
|
9310
9388
|
return this;
|
|
@@ -9331,9 +9409,13 @@ class ClientInstance{
|
|
|
9331
9409
|
// (Don't worry, the underlying sub-system will turn it back into Objects without you need to do anything!)
|
|
9332
9410
|
dataWrapped=stringifyObject(dataWrapped);
|
|
9333
9411
|
|
|
9334
|
-
|
|
9335
|
-
if(!WebsocketImplementation.
|
|
9336
|
-
|
|
9412
|
+
// if(!WebsocketImplementation.useSocketIOImplementation)
|
|
9413
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
9414
|
+
clientSocket.send(dataWrapped);
|
|
9415
|
+
}else{
|
|
9416
|
+
WebsocketImplementation.implementationToUse.send(dataWrapped);
|
|
9417
|
+
// clientSocket.emit(channelNameParam,dataWrapped);
|
|
9418
|
+
}
|
|
9337
9419
|
|
|
9338
9420
|
return this;
|
|
9339
9421
|
}
|
|
@@ -9362,20 +9444,29 @@ class ClientInstance{
|
|
|
9362
9444
|
lognow("DEBUG : CLIENT : doOnConnection !");
|
|
9363
9445
|
|
|
9364
9446
|
const clientSocket=self.clientSocket;
|
|
9365
|
-
|
|
9447
|
+
// if(!WebsocketImplementation.useSocketIOImplementation){
|
|
9448
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
9366
9449
|
// FOR THE WEBSOCKET IMPLEMENTATION :
|
|
9367
9450
|
clientSocket.addEventListener("message", (eventOrMessage)=>{
|
|
9368
9451
|
foreach(self.clientReceptionEntryPoints,(clientReceptionEntryPoint)=>{
|
|
9369
9452
|
clientReceptionEntryPoint.execute(eventOrMessage, clientSocket, self.clientReceptionEntryPoints);
|
|
9370
9453
|
});
|
|
9371
9454
|
});
|
|
9455
|
+
}else{
|
|
9456
|
+
WebsocketImplementation.implementationToUse.receive((eventOrMessage)=>{
|
|
9457
|
+
foreach(self.clientReceptionEntryPoints,(clientReceptionEntryPoint)=>{
|
|
9458
|
+
clientReceptionEntryPoint.execute(eventOrMessage, clientSocket, self.clientReceptionEntryPoints);
|
|
9459
|
+
});
|
|
9460
|
+
});
|
|
9372
9461
|
}
|
|
9373
9462
|
|
|
9374
9463
|
doOnConnection(self, clientSocket);
|
|
9375
9464
|
};
|
|
9376
9465
|
|
|
9377
9466
|
|
|
9378
|
-
|
|
9467
|
+
// if(!WebsocketImplementation.useSocketIOImplementation){
|
|
9468
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
9469
|
+
|
|
9379
9470
|
// FOR THE WEBSOCKET IMPLEMENTATION :
|
|
9380
9471
|
this.clientSocket.addEventListener("open",doAllOnConnection);
|
|
9381
9472
|
|
|
@@ -9386,25 +9477,31 @@ class ClientInstance{
|
|
|
9386
9477
|
}
|
|
9387
9478
|
|
|
9388
9479
|
}else{
|
|
9389
|
-
|
|
9390
|
-
this.clientSocket.on("connect",doAllOnConnection);
|
|
9391
|
-
|
|
9480
|
+
WebsocketImplementation.implementationToUse.initClientSocket(this.clientSocket);
|
|
9392
9481
|
if(!empty(this.onServerLostListeners)){
|
|
9393
|
-
|
|
9482
|
+
WebsocketImplementation.implementationToUse.initOnClose(()=>{
|
|
9394
9483
|
foreach(self.onServerLostListeners,l=>{l.execute(self.clientSocket);});
|
|
9395
9484
|
});
|
|
9396
9485
|
}
|
|
9397
|
-
|
|
9398
|
-
|
|
9399
|
-
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
|
|
9407
|
-
|
|
9486
|
+
// // FOR THE SOCKETIO IMPLEMENTATION :
|
|
9487
|
+
// this.clientSocket.on("connect",doAllOnConnection);
|
|
9488
|
+
//
|
|
9489
|
+
// if(!empty(this.onServerLostListeners)){
|
|
9490
|
+
// this.clientSocket.on("close",()=>{
|
|
9491
|
+
// foreach(self.onServerLostListeners,l=>{l.execute(self.clientSocket);});
|
|
9492
|
+
// });
|
|
9493
|
+
// }
|
|
9494
|
+
//
|
|
9495
|
+
//
|
|
9496
|
+
// // Client ping handling :
|
|
9497
|
+
// // (SocketIO implementation only, the websocket implementation sends back a hidden pong !)
|
|
9498
|
+
// // PING-PONG :
|
|
9499
|
+
// this.receive("protocol",(message)=>{
|
|
9500
|
+
// if(message.type!=="ping") return;
|
|
9501
|
+
// self.send("protocol",{type:"pong"});
|
|
9502
|
+
// // // DBG
|
|
9503
|
+
// // lognow("DEBUG : CLIENT : Pong sent.");
|
|
9504
|
+
// });
|
|
9408
9505
|
}
|
|
9409
9506
|
|
|
9410
9507
|
|
|
@@ -9450,7 +9547,6 @@ class ServerReceptionEntryPoint{
|
|
|
9450
9547
|
// Channel information is stored in exchanged data :
|
|
9451
9548
|
if(dataWrapped.channelName!==this.channelName) return;
|
|
9452
9549
|
|
|
9453
|
-
// TODO : FIXME : Use one single interface !
|
|
9454
9550
|
// Room information is stored in client socket object :
|
|
9455
9551
|
const isClientInRoom=WebsocketImplementation.isInRoom(clientSocketParam, this.clientsRoomsTag);
|
|
9456
9552
|
|
|
@@ -9535,11 +9631,13 @@ class NodeServerInstance{
|
|
|
9535
9631
|
this.serverReceptionEntryPoints.push(serverReceptionEntryPoint);
|
|
9536
9632
|
|
|
9537
9633
|
// SPECIAL FOR THE SOCKETIO IMPLEMENTATION :
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
|
|
9634
|
+
// if(WebsocketImplementation.useSocketIOImplementation){
|
|
9635
|
+
if(WebsocketImplementation.implementationToUse){
|
|
9636
|
+
WebsocketImplementation.implementationToUse.initOnReceiveNodeContext(channelNameParam, serverReceptionEntryPoint);
|
|
9637
|
+
// const channelName=serverReceptionEntryPoint.channelName;
|
|
9638
|
+
// clientSocket.on(channelName, (eventOrMessage)=>{
|
|
9639
|
+
// serverReceptionEntryPoint.execute(eventOrMessage, clientSocket);
|
|
9640
|
+
// });
|
|
9543
9641
|
}
|
|
9544
9642
|
|
|
9545
9643
|
return this;
|
|
@@ -9557,10 +9655,14 @@ class NodeServerInstance{
|
|
|
9557
9655
|
// DBG
|
|
9558
9656
|
lognow("(SERVER) (server sends to all clients)");
|
|
9559
9657
|
|
|
9560
|
-
// TODO : FIXME : Use one single interface !
|
|
9561
9658
|
let serverClients;
|
|
9562
|
-
|
|
9563
|
-
|
|
9659
|
+
// if(!WebsocketImplementation.useSocketIOImplementation)
|
|
9660
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
9661
|
+
serverClients=this.serverSocket.clients;
|
|
9662
|
+
}else{
|
|
9663
|
+
WebsocketImplementation.implementationToUse.getServerClients();
|
|
9664
|
+
// serverClients=this.serverSocket.sockets.sockets;
|
|
9665
|
+
}
|
|
9564
9666
|
|
|
9565
9667
|
|
|
9566
9668
|
serverClients.forEach((clientSocket)=>{
|
|
@@ -9580,9 +9682,13 @@ class NodeServerInstance{
|
|
|
9580
9682
|
// (Don't worry, the underlying sub-system will turn it back into Objects without you need to do anything!)
|
|
9581
9683
|
dataWrapped=stringifyObject(dataWrapped);
|
|
9582
9684
|
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9685
|
+
// if(!WebsocketImplementation.useSocketIOImplementation)
|
|
9686
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
9687
|
+
clientSocket.send(dataWrapped);
|
|
9688
|
+
}else{
|
|
9689
|
+
WebsocketImplementation.implementationToUse.serverSend(clientSocket, dataWrapped);
|
|
9690
|
+
// clientSocket.emit(channelName, dataWrapped);
|
|
9691
|
+
}
|
|
9586
9692
|
|
|
9587
9693
|
});
|
|
9588
9694
|
|
|
@@ -9592,10 +9698,14 @@ class NodeServerInstance{
|
|
|
9592
9698
|
lognow("(SERVER) (server sends to a client)");
|
|
9593
9699
|
|
|
9594
9700
|
|
|
9595
|
-
// TODO : FIXME : Use one single interface !
|
|
9596
9701
|
let clientSocket=clientSocketParam;
|
|
9597
|
-
|
|
9598
|
-
|
|
9702
|
+
// if(!WebsocketImplementation.useSocketIOImplementation)
|
|
9703
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
9704
|
+
if(clientSocket.readyState!==WebSocket.OPEN) return;
|
|
9705
|
+
}else{
|
|
9706
|
+
if(WebsocketImplementation.implementationToUse.isReady(clientSocket)) return;
|
|
9707
|
+
// if(clientSocket.connected) return;
|
|
9708
|
+
}
|
|
9599
9709
|
|
|
9600
9710
|
|
|
9601
9711
|
// Room information is stored in client socket object :
|
|
@@ -9610,9 +9720,13 @@ class NodeServerInstance{
|
|
|
9610
9720
|
dataWrapped=stringifyObject(dataWrapped);
|
|
9611
9721
|
|
|
9612
9722
|
|
|
9613
|
-
|
|
9614
|
-
if(!WebsocketImplementation.
|
|
9615
|
-
|
|
9723
|
+
// if(!WebsocketImplementation.useSocketIOImplementation)
|
|
9724
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
9725
|
+
clientSocket.send(dataWrapped);
|
|
9726
|
+
}else{
|
|
9727
|
+
WebsocketImplementation.implementationToUse.serverSend(clientSocket, dataWrapped);
|
|
9728
|
+
// clientSocket.emit(channelName,dataWrapped);
|
|
9729
|
+
}
|
|
9616
9730
|
|
|
9617
9731
|
}
|
|
9618
9732
|
|
|
@@ -9643,8 +9757,11 @@ class NodeServerInstance{
|
|
|
9643
9757
|
});
|
|
9644
9758
|
};
|
|
9645
9759
|
|
|
9646
|
-
|
|
9760
|
+
// if(!WebsocketImplementation.useSocketIOImplementation){
|
|
9761
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
9647
9762
|
clientSocket.addEventListener("message", doOnMessage);
|
|
9763
|
+
}else{
|
|
9764
|
+
WebsocketImplementation.implementationToUse.initOnMessageReceived(doOnMessage);
|
|
9648
9765
|
}
|
|
9649
9766
|
|
|
9650
9767
|
doOnConnection(this, clientSocket);
|
|
@@ -9652,7 +9769,6 @@ class NodeServerInstance{
|
|
|
9652
9769
|
|
|
9653
9770
|
// DBG
|
|
9654
9771
|
lognow("DEBUG : Starting ping-pong with client : clientSocket.clientId:",clientSocket.clientId);
|
|
9655
|
-
lognow("DEBUG : WebsocketImplementation.useSocketIOImplementation:",WebsocketImplementation.useSocketIOImplementation);
|
|
9656
9772
|
lognow("DEBUG : clientSocket.readyState:",clientSocket.readyState);
|
|
9657
9773
|
|
|
9658
9774
|
|
|
@@ -9668,9 +9784,13 @@ class NodeServerInstance{
|
|
|
9668
9784
|
|
|
9669
9785
|
clientSocket.removeAllListeners();
|
|
9670
9786
|
|
|
9671
|
-
|
|
9672
|
-
if(!WebsocketImplementation.
|
|
9673
|
-
|
|
9787
|
+
// if(!WebsocketImplementation.useSocketIOImplementation)
|
|
9788
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
9789
|
+
clientSocket.terminate();
|
|
9790
|
+
}else{
|
|
9791
|
+
WebsocketImplementation.implementationToUse.terminate();
|
|
9792
|
+
// clientSocket.emit("endConnection");
|
|
9793
|
+
}
|
|
9674
9794
|
|
|
9675
9795
|
if(!empty(self.onClientLostListeners))
|
|
9676
9796
|
foreach(self.onClientLostListeners,l=>{l.execute(clientSocket);});
|
|
@@ -9688,12 +9808,14 @@ class NodeServerInstance{
|
|
|
9688
9808
|
|
|
9689
9809
|
clientSocket.isConnectionAlive=false;
|
|
9690
9810
|
|
|
9691
|
-
|
|
9811
|
+
// if(!WebsocketImplementation.useSocketIOImplementation){
|
|
9812
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
9692
9813
|
// FOR THE WEBSOCKET IMPLEMENTATION :
|
|
9693
9814
|
clientSocket.ping();
|
|
9694
9815
|
}else{
|
|
9695
|
-
|
|
9696
|
-
|
|
9816
|
+
WebsocketImplementation.implementationToUse.ping();
|
|
9817
|
+
// // FOR THE SOCKETIO IMPLEMENTATION :
|
|
9818
|
+
// self.send("protocol",{type:"ping"}, null, clientSocket);
|
|
9697
9819
|
}
|
|
9698
9820
|
|
|
9699
9821
|
|
|
@@ -9701,18 +9823,21 @@ class NodeServerInstance{
|
|
|
9701
9823
|
|
|
9702
9824
|
|
|
9703
9825
|
// PING-PONG :
|
|
9704
|
-
|
|
9826
|
+
// if(!WebsocketImplementation.useSocketIOImplementation){
|
|
9827
|
+
if(!WebsocketImplementation.implementationToUse){
|
|
9705
9828
|
// FOR THE WEBSOCKET IMPLEMENTATION :
|
|
9706
9829
|
clientSocket.on("pong",()=>{
|
|
9707
9830
|
clientSocket.isConnectionAlive=true;
|
|
9708
9831
|
});
|
|
9709
9832
|
}else{
|
|
9710
|
-
|
|
9711
|
-
this.receive("protocol",(message)=>{
|
|
9712
|
-
if(message.type!=="pong") return;
|
|
9833
|
+
WebsocketImplementation.implementationToUse.doOnPong(()=>{
|
|
9713
9834
|
clientSocket.isConnectionAlive=true;
|
|
9714
9835
|
});
|
|
9715
|
-
|
|
9836
|
+
// // FOR THE SOCKETIO IMPLEMENTATION :
|
|
9837
|
+
// this.receive("protocol",(message)=>{
|
|
9838
|
+
// if(message.type!=="pong") return;
|
|
9839
|
+
// clientSocket.isConnectionAlive=true;
|
|
9840
|
+
// });
|
|
9716
9841
|
}
|
|
9717
9842
|
|
|
9718
9843
|
});
|
aotrautils-srv/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aotrautils-srv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1891",
|
|
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)",
|