aotrautils-srv 0.0.944 → 0.0.946

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:46:12)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (15/04/2024-02:50:53)»*/
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:46:12)»*/
5278
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (15/04/2024-02:50:53)»*/
5279
5279
  /*-----------------------------------------------------------------------------*/
5280
5280
 
5281
5281
 
@@ -6067,6 +6067,51 @@ 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
+ const listenerId=nonull(listenerConfig.messageType,"");
6087
+
6088
+ nodeClientInstance.receive(channelNameForResponse, (dataLocal, clientSocket)=>{
6089
+
6090
+
6091
+ // We check if the message matches the condition :
6092
+ if(listenerConfig.condition && !listenerConfig.condition(dataLocal, clientSocket)) return ;
6093
+
6094
+ // We check if we have the same message id:
6095
+ if(resultPromise.messageId!==dataLocal.messageId){
6096
+ // DBG
6097
+ lognow("resultPromise.messageId:"+resultPromise.messageId+"|dataLocal.messageId"+dataLocal.messageId);
6098
+ return;
6099
+ }
6100
+
6101
+ doOnIncomingMessageForResponse(dataLocal, clientSocket);
6102
+ }, resultPromise.clientsRoomsTag, listenerId, {destroyListenerAfterReceiving:true});
6103
+ return resultPromise;
6104
+ }
6105
+ };
6106
+
6107
+ // 2) We send the data :
6108
+ nodeClientInstance.send(channelNameParam, data, clientsRoomsTag);
6109
+
6110
+
6111
+ return resultPromise;
6112
+ },
6113
+
6114
+
6070
6115
  send:(channelNameParam, data, clientsRoomsTag=null)=>{
6071
6116
 
6072
6117
  // // DBG
@@ -6266,16 +6311,12 @@ WebsocketImplementation={
6266
6311
  },
6267
6312
 
6268
6313
 
6269
-
6270
-
6271
-
6272
6314
 
6273
-
6315
+ // TODO : FIXME : DUPLICATED CODE !
6274
6316
  sendChainable:(channelNameParam, data, clientsRoomsTag=null)=>{
6275
6317
 
6276
-
6277
6318
  // DBG
6278
- lognow(">>>>>>sendChainable("+channelNameParam+"):data:",data);
6319
+ lognow(">>>>>>sendChainable BROWSER CLIENT ("+channelNameParam+"):data:",data);
6279
6320
 
6280
6321
  // We add a message id :
6281
6322
  const messageId=getUUID();
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.944",
3
+ "version": "0.0.946",
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)",