aotrautils 0.0.460 → 0.0.461

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 (26/01/2023-23:48:15)»*/
3
+ /*utils COMMONS library associated with aotra version : «1_29072022-2359 (27/01/2023-22:17:41)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -4864,7 +4864,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4864
4864
 
4865
4865
 
4866
4866
 
4867
- /*utils CLIENT library associated with aotra version : «1_29072022-2359 (26/01/2023-23:48:15)»*/
4867
+ /*utils CLIENT library associated with aotra version : «1_29072022-2359 (27/01/2023-22:17:41)»*/
4868
4868
  /*-----------------------------------------------------------------------------*/
4869
4869
  /* ## Utility global methods in a browser (htmljs) client environment.
4870
4870
  *
@@ -12986,7 +12986,7 @@ createOritaMicroClient=function(url, port, isNode=false){
12986
12986
  };
12987
12987
 
12988
12988
 
12989
- /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (26/01/2023-23:48:15)»*/
12989
+ /*utils GEOMETRY library associated with aotra version : «1_29072022-2359 (27/01/2023-22:17:41)»*/
12990
12990
  /*-----------------------------------------------------------------------------*/
12991
12991
 
12992
12992
 
@@ -14214,7 +14214,7 @@ function rayVsUnitSphereClosestPoint(p, r) {
14214
14214
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
14215
14215
 
14216
14216
  AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
14217
- /*utils SERVER library associated with aotra version : «1_29072022-2359 (26/01/2023-23:48:15)»*/
14217
+ /*utils SERVER library associated with aotra version : «1_29072022-2359 (27/01/2023-22:17:41)»*/
14218
14218
  /*-----------------------------------------------------------------------------*/
14219
14219
 
14220
14220
 
@@ -15115,7 +15115,7 @@ WebsocketImplementation={
15115
15115
 
15116
15116
  receptionEntryPoints:[],
15117
15117
 
15118
- receive:(channelNameParam, doOnIncomingMessage, clientsRoomsTag=null, receptionEntryPointId=null)=>{
15118
+ receive:(channelNameParam, doOnIncomingMessage, clientsRoomsTag=null, receptionEntryPointId=null, listenerConfig={destroyListenerAfterReceiving:false})=>{
15119
15119
 
15120
15120
 
15121
15121
  // DBG
@@ -15127,7 +15127,7 @@ WebsocketImplementation={
15127
15127
  clientsRoomsTag:clientsRoomsTag,
15128
15128
  // TODO : ADD TO ALL OTHER SUBSYSTEMS !
15129
15129
  id:receptionEntryPointId,
15130
-
15130
+ listenerConfig:listenerConfig,
15131
15131
  execute:(eventOrMessage)=>{
15132
15132
 
15133
15133
  const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
@@ -15143,9 +15143,11 @@ WebsocketImplementation={
15143
15143
  // Room information is stored in client socket object :
15144
15144
  if(!WebsocketImplementation.isInRoom(clientSocket,clientsRoomsTag)) return;
15145
15145
 
15146
- if(doOnIncomingMessage) doOnIncomingMessage(dataWrapped.data, clientSocket);
15147
-
15146
+ if(doOnIncomingMessage)
15147
+ doOnIncomingMessage(dataWrapped.data, clientSocket);
15148
15148
 
15149
+ if(listenerConfig && listenerConfig.destroyListenerAfterReceiving)
15150
+ remove(browserInstance.receptionEntryPoints,receptionEntryPoint);
15149
15151
  }
15150
15152
  };
15151
15153
 
@@ -15153,6 +15155,8 @@ WebsocketImplementation={
15153
15155
  if(!contains(browserInstance.receptionEntryPoints,(l)=>(l.id && receptionEntryPoint.id && l.id===receptionEntryPoint.id)))
15154
15156
  browserInstance.receptionEntryPoints.push(receptionEntryPoint);
15155
15157
 
15158
+ // DBG
15159
+ lognow("browserInstance.receptionEntryPoints("+browserInstance.receptionEntryPoints.length+"):",browserInstance.receptionEntryPoints);
15156
15160
 
15157
15161
  return browserInstance;
15158
15162
  },
@@ -15170,18 +15174,32 @@ WebsocketImplementation={
15170
15174
  // DBG
15171
15175
  lognow(">>>>>>sendChainable("+channelNameParam+"):data:",data);
15172
15176
 
15177
+ // We add a message id :
15178
+ const messageId=getUUID();
15173
15179
 
15180
+ data.messageId=messageId;
15174
15181
  browserInstance.send(channelNameParam, data, clientsRoomsTag);
15175
15182
 
15176
15183
  const resultPromise={
15177
15184
  clientsRoomsTag:clientsRoomsTag,
15185
+ messageId:messageId,
15178
15186
  thenWhenReceiveMessageType:(channelNameForResponse, listenerConfig={messageType:"",condition:()=>true}, doOnIncomingMessageForResponse)=>{
15179
15187
  const listenerId=nonull(listenerConfig.messageType,"");
15180
- browserInstance.receive(channelNameForResponse, (data, clientSocket)=>{
15188
+
15189
+ const self=this;
15190
+ browserInstance.receive(channelNameForResponse, (dataLocal, clientSocket)=>{
15191
+
15192
+ if(listenerConfig.condition && !listenerConfig.condition(dataLocal, clientSocket)) return ;
15193
+
15194
+ // We check if we have the same message id:
15195
+ if(self.messageId!==dataLocal.messageId){
15196
+ // DBG
15197
+ lognow("self.messageId:"+self.messageId+"|dataLocal.messageId"+dataLocal.messageId);
15198
+ return;
15199
+ }
15181
15200
 
15182
- if(listenerConfig.condition && !listenerConfig.condition(data, clientSocket)) return ;
15183
- doOnIncomingMessageForResponse(data, clientSocket);
15184
- }, this.clientsRoomsTag, listenerId);
15201
+ doOnIncomingMessageForResponse(dataLocal, clientSocket);
15202
+ }, this.clientsRoomsTag, listenerId, {destroyListenerAfterReceiving:true});
15185
15203
  return this;
15186
15204
  }
15187
15205
  };
aotrautils/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.460",
3
+ "version": "0.0.461",
4
4
  "main": "aotrautils.build.js",
5
5
  "description": "A library for vanilla javascript utils (client-side) used in aotra javascript CMS",
6
6
  "author": "Jeremie Ratomposon <info@alqemia.com> (https://alqemia.com)",