aotrautils-srv 0.0.153 → 0.0.156

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.0.0.000 (17/07/2022-03:50:48)»*/
3
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (17/07/2022-04:02:53)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -4828,7 +4828,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4828
4828
 
4829
4829
 
4830
4830
 
4831
- /*utils SERVER library associated with aotra version : «1.0.0.000 (17/07/2022-03:50:48)»*/
4831
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (17/07/2022-04:02:53)»*/
4832
4832
  /*-----------------------------------------------------------------------------*/
4833
4833
 
4834
4834
 
@@ -5188,24 +5188,9 @@ WebsocketImplementation={
5188
5188
  }
5189
5189
 
5190
5190
 
5191
- // DBG
5192
- lognow(" Channel information:dataWrapped",dataWrapped);
5193
- lognow(" Channel information:dataWrapped",JSON.stringify(dataWrapped));
5194
- lognow(" Channel information:dataWrapped.channelName«"+dataWrapped.channelName+"»");
5195
- lognow(" Channel information:receptionEntryPoint.channelName«"+receptionEntryPoint.channelName+"»");
5196
- lognow(" C1",(dataWrapped.channelName!=receptionEntryPoint.channelName));
5197
- lognow(" C2",(dataWrapped.channelName!==receptionEntryPoint.channelName));
5198
- lognow(" C11",(dataWrapped.channelName==receptionEntryPoint.channelName));
5199
- lognow(" C22",(dataWrapped.channelName===receptionEntryPoint.channelName));
5200
- lognow(" C111",(dataWrapped.channelName.normalize()==receptionEntryPoint.channelName.normalize()));
5201
- lognow(" C222",(dataWrapped.channelName.normalize()===receptionEntryPoint.channelName.normalize()));
5202
-
5203
-
5204
- ////
5205
- // CURRENT 5 : PROBLEM IS HERE :
5206
5191
 
5207
5192
  // Channel information is stored in exchanged data :
5208
- if(dataWrapped.channelName.normalize()!==receptionEntryPoint.channelName.normalize()) return;
5193
+ if(dataWrapped.channelName!==receptionEntryPoint.channelName) return;
5209
5194
 
5210
5195
 
5211
5196
  const clientSocket=clientSocketParam;
@@ -5229,16 +5214,9 @@ WebsocketImplementation={
5229
5214
 
5230
5215
 
5231
5216
  if(!WebsocketImplementation.useSocketIOImplementation) clientSocketParam.addEventListener("message", doOnMessage);
5232
- else{
5233
-
5234
- // DBG
5235
- clientSocketParam.onAny((event,args) => { console.log(`MAIS PUTAIN : ${event}:`,args); });
5236
- clientSocketParam.on(channelName,(args, clientSocket) => { console.log(`MAIS OSKOUR :${args} ${clientSocket}`); });
5217
+ else clientSocketParam.on(channelName, doOnMessage);
5237
5218
 
5238
5219
 
5239
-
5240
- clientSocketParam.on(channelName, doOnMessage);
5241
- }
5242
5220
 
5243
5221
 
5244
5222
 
@@ -5265,7 +5243,8 @@ WebsocketImplementation={
5265
5243
  // TODO : FIXME : Use one single interface !
5266
5244
  let serverClients;
5267
5245
  if(!WebsocketImplementation.useSocketIOImplementation) serverClients=nodeServerInstance.serverSocket.clients;
5268
- else serverClients=nodeServerInstance.serverSocket.sockets.clients();
5246
+ // OLD: else serverClients=nodeServerInstance.serverSocket.sockets.clients();
5247
+ else serverClients=nodeServerInstance.serverSocket.sockets;
5269
5248
 
5270
5249
  serverClients.forEach((clientSocket)=>{
5271
5250
 
@@ -5446,7 +5425,8 @@ WebsocketImplementation={
5446
5425
 
5447
5426
  // TODO : FIXME : Use one single interface !
5448
5427
  if(!WebsocketImplementation.useSocketIOImplementation) serverClients=nodeServerInstance.serverSocket.clients;
5449
- else serverClients=nodeServerInstance.serverSocket.sockets.clients();
5428
+ // OLD : else serverClients=nodeServerInstance.serverSocket.sockets.clients();
5429
+ else serverClients=nodeServerInstance.serverSocket.sockets;
5450
5430
 
5451
5431
  serverClients.forEach((clientSocket)=>{
5452
5432
  clearInterval(clientSocket.stateCheckInterval);
@@ -5685,7 +5665,17 @@ WebsocketImplementation={
5685
5665
  // const dataWrapped=JSON.parse(message);
5686
5666
  // dataWrapped=getAt(dataWrapped,0);// We get the root element
5687
5667
 
5688
- const dataWrapped=(WebsocketImplementation.useFlatStrings?JSON.parse(message):message);
5668
+
5669
+ let dataWrapped=message;
5670
+ try{
5671
+ dataWrapped=(WebsocketImplementation.useFlatStrings || isString(message)?JSON.parse(message):message);
5672
+ }catch(error1){
5673
+ // TRACE
5674
+ lognow(`ERROR : Failed to parse JSON for string «${dataWrapped}»`,error1);
5675
+ dataWrapped=(isString(message)?message:JSON.stringify(message));
5676
+ }
5677
+
5678
+
5689
5679
 
5690
5680
 
5691
5681
  // Channel information is stored in exchanged data :
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.153",
3
+ "version": "0.0.156",
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)",