aotrautils-srv 0.0.945 → 0.0.947

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/04/2024-02:47:32)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (15/04/2024-03:00:48)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -5275,7 +5275,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
5275
5275
 
5276
5276
 
5277
5277
 
5278
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (15/04/2024-02:47:32)»*/
5278
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (15/04/2024-03:00:48)»*/
5279
5279
  /*-----------------------------------------------------------------------------*/
5280
5280
 
5281
5281
 
@@ -6067,6 +6067,52 @@ WebsocketImplementation={
6067
6067
  },
6068
6068
 
6069
6069
 
6070
+
6071
+ // TODO : FIXME : DUPLICATED CODE !
6072
+ sendChainable:(channelNameParam, data, clientsRoomsTag=null)=>{
6073
+
6074
+ // DBG
6075
+ lognow(">>>>>>sendChainable NODE CLIENT ("+channelNameParam+"):data:",data);
6076
+
6077
+ // We add a message id :
6078
+ const messageId=getUUID();
6079
+ data.messageId=messageId;
6080
+
6081
+ // 1) We prepare the reception :
6082
+ const resultPromise={
6083
+ clientsRoomsTag:clientsRoomsTag,
6084
+ messageId:messageId,
6085
+ thenWhenReceiveMessageType:(channelNameForResponse, listenerConfig={messageType:"",condition:()=>true}, doOnIncomingMessageForResponse)=>{
6086
+ listenerConfig=nonull(listenerConfig,{messageType:"",condition:()=>true});
6087
+ const listenerId=nonull(listenerConfig.messageType,"");
6088
+
6089
+ nodeClientInstance.receive(channelNameForResponse, (dataLocal, clientSocket)=>{
6090
+
6091
+
6092
+ // We check if the message matches the condition :
6093
+ if(listenerConfig.condition && !listenerConfig.condition(dataLocal, clientSocket)) return ;
6094
+
6095
+ // We check if we have the same message id:
6096
+ if(resultPromise.messageId!==dataLocal.messageId){
6097
+ // DBG
6098
+ lognow("resultPromise.messageId:"+resultPromise.messageId+"|dataLocal.messageId"+dataLocal.messageId);
6099
+ return;
6100
+ }
6101
+
6102
+ doOnIncomingMessageForResponse(dataLocal, clientSocket);
6103
+ }, resultPromise.clientsRoomsTag, listenerId, {destroyListenerAfterReceiving:true});
6104
+ return resultPromise;
6105
+ }
6106
+ };
6107
+
6108
+ // 2) We send the data :
6109
+ nodeClientInstance.send(channelNameParam, data, clientsRoomsTag);
6110
+
6111
+
6112
+ return resultPromise;
6113
+ },
6114
+
6115
+
6070
6116
  send:(channelNameParam, data, clientsRoomsTag=null)=>{
6071
6117
 
6072
6118
  // // DBG
@@ -6266,16 +6312,12 @@ WebsocketImplementation={
6266
6312
  },
6267
6313
 
6268
6314
 
6269
-
6270
-
6271
-
6272
6315
 
6273
-
6316
+ // TODO : FIXME : DUPLICATED CODE !
6274
6317
  sendChainable:(channelNameParam, data, clientsRoomsTag=null)=>{
6275
6318
 
6276
-
6277
6319
  // DBG
6278
- lognow(">>>>>>sendChainable("+channelNameParam+"):data:",data);
6320
+ lognow(">>>>>>sendChainable BROWSER CLIENT ("+channelNameParam+"):data:",data);
6279
6321
 
6280
6322
  // We add a message id :
6281
6323
  const messageId=getUUID();
@@ -6286,6 +6328,7 @@ WebsocketImplementation={
6286
6328
  clientsRoomsTag:clientsRoomsTag,
6287
6329
  messageId:messageId,
6288
6330
  thenWhenReceiveMessageType:(channelNameForResponse, listenerConfig={messageType:"",condition:()=>true}, doOnIncomingMessageForResponse)=>{
6331
+ listenerConfig=nonull(listenerConfig,{messageType:"",condition:()=>true});
6289
6332
  const listenerId=nonull(listenerConfig.messageType,"");
6290
6333
 
6291
6334
  browserInstance.receive(channelNameForResponse, (dataLocal, clientSocket)=>{
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.945",
3
+ "version": "0.0.947",
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)",