aotrautils-srv 0.0.1813 → 0.0.1815

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_29072022-2359 (15/03/2026-14:56:43)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (16/03/2026-18:06:10)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -3209,7 +3209,7 @@ window.containsIgnoreCase=function(str, chunk,/*OPTIONAL*/useRegexp){
3209
3209
  };
3210
3210
 
3211
3211
  window.isString=function (str){
3212
- return str && typeof(str)==="string";
3212
+ return str!=null && typeof(str)==="string";
3213
3213
  };
3214
3214
 
3215
3215
  window.containsOneOf=function(container, objectsToFind,/*OPTIONAL*/useRegexp=false,searchInKeysOnly=false){
@@ -5076,7 +5076,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
5076
5076
 
5077
5077
 
5078
5078
 
5079
- /*utils AI library associated with aotra version : «1_29072022-2359 (15/03/2026-14:56:43)»*/
5079
+ /*utils AI library associated with aotra version : «1_29072022-2359 (16/03/2026-18:06:10)»*/
5080
5080
  /*-----------------------------------------------------------------------------*/
5081
5081
 
5082
5082
 
@@ -5222,7 +5222,7 @@ getOpenAIAPIClient=(modelName, apiURL, agentRole, defaultPrompt)=>{
5222
5222
 
5223
5223
 
5224
5224
 
5225
- /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (15/03/2026-14:56:43)»*/
5225
+ /*utils CONSOLE library associated with aotra version : «1_29072022-2359 (16/03/2026-18:06:10)»*/
5226
5226
  /*-----------------------------------------------------------------------------*/
5227
5227
 
5228
5228
 
@@ -5270,10 +5270,14 @@ class AORTACServerCell{
5270
5270
 
5271
5271
  this.quorumNumber=quorumNumber;
5272
5272
  this.selfOrigin=selfOrigin;
5273
- const splits=splitURL(this.selfOrigin);
5274
- this.protocol=nonull(splits.protocol,"ws");
5275
- this.host=nonull(splits.host,"localhost");
5276
- this.port=nonull(splits.port,"30000");
5273
+ const infos=splitURL(this.selfOrigin);
5274
+
5275
+ //DBG
5276
+ lognow("infos:::::::::::::",infos);
5277
+
5278
+ this.protocol=nonull(infos.protocol,"ws");
5279
+ this.host=nonull(infos.host,"localhost");
5280
+ this.port=nonull(infos.port,"30000");
5277
5281
  this.sslConfig=sslConfig;
5278
5282
 
5279
5283
  this.server=null;
@@ -5381,10 +5385,10 @@ class AORTACServerCell{
5381
5385
  // We try to connect to all outcoming cells :
5382
5386
  foreach(this.outcomingCells, (outcomingCell, outcomingCellOrigin)=>{
5383
5387
 
5384
- const splits=splitURL(outcomingCellOrigin);
5385
- const outcomingCellProtocol=nonull(splits.protocol,"ws");
5386
- const outcomingCellHost=nonull(splits.host,"localhost");
5387
- const outcomingCellPort=nonull(splits.port,"40000");
5388
+ const infos=splitURL(outcomingCellOrigin);
5389
+ const outcomingCellProtocol=nonull(infos.protocol,"ws");
5390
+ const outcomingCellHost=nonull(infos.host,"localhost");
5391
+ const outcomingCellPort=nonull(infos.port,"40000");
5388
5392
 
5389
5393
  const clientInstance=initClient(true, false, (socketToServerClientInstance)=>{
5390
5394
 
@@ -5850,7 +5854,7 @@ window.ao=(incompleteModelObjectToDecorate)=>{
5850
5854
 
5851
5855
 
5852
5856
 
5853
- window.getAORTACServerNode=function(quorumNumber=1,selfOrigin="ws://127.0.0.1:40000", outcomingCellsOrigins=[], model, controller){
5857
+ window.getAORTACServerNode=function(quorumNumber=1, selfOrigin="ws://127.0.0.1:40000", outcomingCellsOrigins=[], model, controller){
5854
5858
  //return new AORTACServerNode("node_"+getUUID("short"), selfOrigin, outcomingCellsOrigins, model, controller);
5855
5859
  if(window.aortacCServerNodeInstance){
5856
5860
  // TRACE
@@ -6251,6 +6255,91 @@ if(typeof(window)==="undefined") window=global;
6251
6255
  // ==================================================================================================================
6252
6256
 
6253
6257
 
6258
+
6259
+
6260
+ // -Client :
6261
+
6262
+ // TODO : Use everywhere it's applicable !
6263
+ initClient=function(isNodeContext=true, useSocketIOImplementation=/*DEBUG*/false, doOnServerConnection=null, url, /*OPTIONAL*/port=25000, isSecure=true, /*OPTIONAL*/timeout=10000, /*OPTIONAL*/selfParam=null){
6264
+ let aotraClient={};
6265
+
6266
+ aotraClient.client={};
6267
+ aotraClient.client.start=function(){
6268
+
6269
+ // DBG
6270
+ lognow("INFO : Setting up client :...");
6271
+
6272
+ let socketToServerClientInstance=WebsocketImplementation.getStatic(isNodeContext, useSocketIOImplementation).connectToServer(url, port, isSecure, timeout);
6273
+ if(!socketToServerClientInstance){
6274
+ // TRACE
6275
+ lognow("ERROR : CLIENT : Could not get socketToServerClientInstance, aborting client connection.");
6276
+ return null;
6277
+ }
6278
+
6279
+ // When client is connected, we execute the callback :
6280
+ // CAUTION : MUST BE CALLED ONLY ONCE !
6281
+ socketToServerClientInstance.onConnectionToServer(()=>{
6282
+ if(doOnServerConnection){
6283
+ if(selfParam) doOnServerConnection.apply(selfParam,[socketToServerClientInstance]);
6284
+ else doOnServerConnection(socketToServerClientInstance);
6285
+ }
6286
+
6287
+
6288
+ });
6289
+
6290
+ // // Errors handling :
6291
+ // if(doOnError && useSocketIOImplementation /*TODO : FIXME: FOR NOW, ONLY WORKS FOR SOCKET.IO IMPLEMENTATION !'*/){
6292
+ //
6293
+ //// // DBG
6294
+ //// lognow(">>> serverSocket:",serverSocket);
6295
+ //
6296
+ //
6297
+ // const errorMethod=function(){
6298
+ // // TRACE
6299
+ // lognow("ERROR : CLIENT : Client encountered an error while trying to connect to server.");
6300
+ //
6301
+ // if(selfParam) doOnError.apply(selfParam);
6302
+ // else doOnError();
6303
+ // };
6304
+ //
6305
+ // socketToServerClientInstance.clientSocket.on("connect_error", errorMethod);
6306
+ //
6307
+ //// // DOES NOT SEEM TO WORK :
6308
+ //// socketToServerClientInstance.on("connect_failed", errorMethod);
6309
+ //// // DOES NOT SEEM TO WORK :
6310
+ //// socketToServerClientInstance.on("error", errorMethod);
6311
+ //
6312
+ // }
6313
+ //
6314
+ // // Data messages handling :
6315
+ // if(doOnMessage){
6316
+ // socketToServerClientInstance.onIncomingMessage((message)=>{
6317
+ // if(selfParam) doOnMessage.apply(selfParam,[message]);
6318
+ // else doOnMessage(message);
6319
+ // });
6320
+ // }
6321
+
6322
+ // DBG
6323
+ lognow("aotraClient.client:",aotraClient.client);
6324
+
6325
+ // DBG
6326
+ // aotraClient.clientSocket.addEventListener("close",()=>{
6327
+ // // TRACE
6328
+ // lognow("WARN : CONNECTION CLOSED !");
6329
+ // });
6330
+
6331
+
6332
+ aotraClient.client.socketToServerClientInstance=socketToServerClientInstance;
6333
+
6334
+ return aotraClient;
6335
+ };
6336
+
6337
+
6338
+ return aotraClient;
6339
+ }
6340
+
6341
+
6342
+
6254
6343
  class ClientReceptionEntryPoint{
6255
6344
 
6256
6345
  constructor(channelNameParam, entryPointId, clientsRoomsTag, listenerConfig, doOnIncomingMessage){
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.1813",
3
+ "version": "0.0.1815",
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)",