aotrautils 0.0.164 → 0.0.167

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-14:25:57)»*/
3
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (17/07/2022-14:49:17)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -4828,7 +4828,7 @@ AOTRAUTILS_LIB_IS_LOADED=true;
4828
4828
 
4829
4829
 
4830
4830
 
4831
- /*utils CLIENT library associated with aotra version : «1.0.0.000 (17/07/2022-14:25:57)»*/
4831
+ /*utils CLIENT library associated with aotra version : «1.0.0.000 (17/07/2022-14:49:17)»*/
4832
4832
  /*-----------------------------------------------------------------------------*/
4833
4833
  /* ## Utility global methods in a browser (htmljs) client environment.
4834
4834
  *
@@ -11678,7 +11678,7 @@ createFusrodaClient=function(doOnClientReady, doOnDataReception, urlParam=null,
11678
11678
 
11679
11679
 
11680
11680
 
11681
- /*utils GEOMETRY library associated with aotra version : «1.0.0.000 (17/07/2022-14:25:57)»*/
11681
+ /*utils GEOMETRY library associated with aotra version : «1.0.0.000 (17/07/2022-14:49:17)»*/
11682
11682
  /*-----------------------------------------------------------------------------*/
11683
11683
 
11684
11684
 
@@ -12884,7 +12884,7 @@ function rayVsUnitSphereClosestPoint(p, r) {
12884
12884
  // MUST REMAIN AT THE END OF THIS LIBRARY FILE !
12885
12885
 
12886
12886
  AOTRAUTILS_GEOMETRY_LIB_IS_LOADED=true;
12887
- /*utils SERVER library associated with aotra version : «1.0.0.000 (17/07/2022-14:25:57)»*/
12887
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (17/07/2022-14:49:17)»*/
12888
12888
  /*-----------------------------------------------------------------------------*/
12889
12889
 
12890
12890
 
@@ -13169,6 +13169,28 @@ WebsocketImplementation={
13169
13169
  },
13170
13170
 
13171
13171
 
13172
+ /*private*/getMessageDataBothImplementations:(eventOrMessageParam)=>{
13173
+
13174
+ const eventOrMessage=(!WebsocketImplementation.useSocketIOImplementation?eventOrMessageParam.data:eventOrMessageParam);
13175
+
13176
+ let dataResult=eventOrMessage;
13177
+
13178
+ ////
13179
+ // DBG
13180
+ lognow(" SERVER RECEIVED 1:",eventOrMessage);
13181
+
13182
+ try{
13183
+ dataResult=(WebsocketImplementation.useFlatStrings || isString(eventOrMessage)?JSON.parse(eventOrMessage):eventOrMessage);
13184
+ }catch(error1){
13185
+ // TRACE
13186
+ lognow(`ERROR : Failed to parse JSON for string «${dataResult}»`,error1);
13187
+ dataResult=(isString(eventOrMessage)?eventOrMessage:JSON.stringify(eventOrMessage));
13188
+ }
13189
+
13190
+ return dataResult;
13191
+ },
13192
+
13193
+
13172
13194
  getServer:(listenableServer)=>{
13173
13195
 
13174
13196
  if(!WebsocketImplementation.isNodeContext){
@@ -13229,21 +13251,18 @@ WebsocketImplementation={
13229
13251
  // nodeServerInstance.onConnectionToClient((serverParam, clientSocketParam)=>{
13230
13252
 
13231
13253
  // TODO : Find a way to remove this !
13232
- const doOnMessage=(message)=>{
13254
+ const doOnMessage=(eventOrMessage)=>{
13233
13255
 
13234
13256
  // dataWrapped=JSON.parse(dataWrapped);
13235
13257
  // dataWrapped=getAt(dataWrapped,0);// We get the root element
13258
+
13236
13259
 
13237
- let dataWrapped=message;
13238
- try{
13239
- dataWrapped=(WebsocketImplementation.useFlatStrings || isString(message)?JSON.parse(message):message);
13240
- }catch(error1){
13241
- // TRACE
13242
- lognow(`ERROR : Failed to parse JSON for string «${dataWrapped}»`,error1);
13243
- dataWrapped=(isString(message)?message:JSON.stringify(message));
13244
- }
13245
-
13246
-
13260
+ const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
13261
+ ////
13262
+ // DBG
13263
+ lognow(" SERVER RECEIVED 2:",dataWrapped);
13264
+
13265
+
13247
13266
 
13248
13267
  // Channel information is stored in exchanged data :
13249
13268
  if(dataWrapped.channelName!==receptionEntryPoint.channelName) return;
@@ -13468,7 +13487,6 @@ WebsocketImplementation={
13468
13487
  nodeServerInstance.receive("protocol",(message, clientSocket)=>{
13469
13488
 
13470
13489
  if(message.type!=="joinRoom" || !clientSocket) return;
13471
-
13472
13490
  nodeServerInstance.addToRoom(clientSocket, message.clientRoomTag);
13473
13491
 
13474
13492
  });
@@ -13555,13 +13573,13 @@ WebsocketImplementation={
13555
13573
  clientsRoomsTag:clientsRoomsTag,
13556
13574
  execute:(clientSocketParam)=>{
13557
13575
 
13558
- const doOnMessage=(message)=>{
13576
+ const doOnMessage=(eventOrMessage)=>{
13559
13577
 
13560
13578
  // dataWrapped=JSON.parse(dataWrapped);
13561
13579
  // dataWrapped=getAt(dataWrapped,0);// We get the root element
13562
-
13563
- const dataWrapped=(WebsocketImplementation.useFlatStrings?JSON.parse(message):message);
13580
+ // const dataWrapped=(WebsocketImplementation.useFlatStrings?JSON.parse(eventOrMessage):eventOrMessage);
13564
13581
 
13582
+ const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
13565
13583
 
13566
13584
  // Channel information is stored in exchanged data :
13567
13585
  if(dataWrapped.channelName && dataWrapped.channelName!==channelName) return;
@@ -13631,9 +13649,7 @@ WebsocketImplementation={
13631
13649
  join:(clientRoomTag)=>{
13632
13650
  // Join room client part protocol :
13633
13651
  const message={type:"joinRoom",clientRoomTag:clientRoomTag};
13634
-
13635
13652
  nodeClientInstance.send("protocol",message);
13636
-
13637
13653
  },
13638
13654
 
13639
13655
 
@@ -13711,26 +13727,14 @@ WebsocketImplementation={
13711
13727
  // DBG
13712
13728
  lognow("INFO : (CLIENT-BROWSER) SETTING UP RECEIVE for :",channelName);
13713
13729
 
13714
- const doOnMessage=(message)=>{
13730
+ const doOnMessage=(eventOrMessage)=>{
13715
13731
 
13716
- // // DBG
13717
- // lognow("!!! RECEIVED : message",message);
13718
13732
 
13719
- // OLD : let dataWrapped=JSON.parse(event.data);
13720
- // const dataWrapped=JSON.parse(message);
13721
- // dataWrapped=getAt(dataWrapped,0);// We get the root element
13722
-
13723
-
13724
- let dataWrapped=message;
13725
- try{
13726
- dataWrapped=(WebsocketImplementation.useFlatStrings || isString(message)?JSON.parse(message):message);
13727
- }catch(error1){
13728
- // TRACE
13729
- lognow(`ERROR : Failed to parse JSON for string «${dataWrapped}»`,error1);
13730
- dataWrapped=(isString(message)?message:JSON.stringify(message));
13731
- }
13732
-
13733
-
13733
+ const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
13734
+
13735
+ ////
13736
+ // DBG
13737
+ lognow(" CLIENT-BROWSER RECEIVED 2:",dataWrapped);
13734
13738
 
13735
13739
 
13736
13740
  // Channel information is stored in exchanged data :
aotrautils/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils",
3
- "version": "0.0.164",
3
+ "version": "0.0.167",
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)",