aotrautils 0.0.163 → 0.0.166

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:24:39)»*/
3
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (17/07/2022-14:45:39)»*/
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:24:39)»*/
4831
+ /*utils CLIENT library associated with aotra version : «1.0.0.000 (17/07/2022-14:45:39)»*/
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:24:39)»*/
11681
+ /*utils GEOMETRY library associated with aotra version : «1.0.0.000 (17/07/2022-14:45:39)»*/
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:24:39)»*/
12887
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (17/07/2022-14:45:39)»*/
12888
12888
  /*-----------------------------------------------------------------------------*/
12889
12889
 
12890
12890
 
@@ -13169,6 +13169,26 @@ WebsocketImplementation={
13169
13169
  },
13170
13170
 
13171
13171
 
13172
+ /*private*/getMessageDataBothImplementations:(eventOrMessage)=>{
13173
+
13174
+ const dataResult=(!WebsocketImplementation.useSocketIOImplementation?eventOrMessage.data:eventOrMessage);
13175
+
13176
+ ////
13177
+ // DBG
13178
+ lognow(" SERVER RECEIVED 1:",eventOrMessage);
13179
+
13180
+ try{
13181
+ dataResult=(WebsocketImplementation.useFlatStrings || isString(eventOrMessage)?JSON.parse(eventOrMessage):eventOrMessage);
13182
+ }catch(error1){
13183
+ // TRACE
13184
+ lognow(`ERROR : Failed to parse JSON for string «${dataResult}»`,error1);
13185
+ dataResult=(isString(eventOrMessage)?eventOrMessage:JSON.stringify(eventOrMessage));
13186
+ }
13187
+
13188
+ return dataResult;
13189
+ },
13190
+
13191
+
13172
13192
  getServer:(listenableServer)=>{
13173
13193
 
13174
13194
  if(!WebsocketImplementation.isNodeContext){
@@ -13229,21 +13249,18 @@ WebsocketImplementation={
13229
13249
  // nodeServerInstance.onConnectionToClient((serverParam, clientSocketParam)=>{
13230
13250
 
13231
13251
  // TODO : Find a way to remove this !
13232
- const doOnMessage=(message)=>{
13252
+ const doOnMessage=(eventOrMessage)=>{
13233
13253
 
13234
13254
  // dataWrapped=JSON.parse(dataWrapped);
13235
13255
  // dataWrapped=getAt(dataWrapped,0);// We get the root element
13256
+
13236
13257
 
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
-
13258
+ const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
13259
+ ////
13260
+ // DBG
13261
+ lognow(" SERVER RECEIVED 2:",dataWrapped);
13262
+
13263
+
13247
13264
 
13248
13265
  // Channel information is stored in exchanged data :
13249
13266
  if(dataWrapped.channelName!==receptionEntryPoint.channelName) return;
@@ -13468,7 +13485,6 @@ WebsocketImplementation={
13468
13485
  nodeServerInstance.receive("protocol",(message, clientSocket)=>{
13469
13486
 
13470
13487
  if(message.type!=="joinRoom" || !clientSocket) return;
13471
-
13472
13488
  nodeServerInstance.addToRoom(clientSocket, message.clientRoomTag);
13473
13489
 
13474
13490
  });
@@ -13555,13 +13571,13 @@ WebsocketImplementation={
13555
13571
  clientsRoomsTag:clientsRoomsTag,
13556
13572
  execute:(clientSocketParam)=>{
13557
13573
 
13558
- const doOnMessage=(message)=>{
13574
+ const doOnMessage=(eventOrMessage)=>{
13559
13575
 
13560
13576
  // dataWrapped=JSON.parse(dataWrapped);
13561
13577
  // dataWrapped=getAt(dataWrapped,0);// We get the root element
13562
-
13563
- const dataWrapped=(WebsocketImplementation.useFlatStrings?JSON.parse(message):message);
13578
+ // const dataWrapped=(WebsocketImplementation.useFlatStrings?JSON.parse(eventOrMessage):eventOrMessage);
13564
13579
 
13580
+ const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
13565
13581
 
13566
13582
  // Channel information is stored in exchanged data :
13567
13583
  if(dataWrapped.channelName && dataWrapped.channelName!==channelName) return;
@@ -13631,9 +13647,7 @@ WebsocketImplementation={
13631
13647
  join:(clientRoomTag)=>{
13632
13648
  // Join room client part protocol :
13633
13649
  const message={type:"joinRoom",clientRoomTag:clientRoomTag};
13634
-
13635
13650
  nodeClientInstance.send("protocol",message);
13636
-
13637
13651
  },
13638
13652
 
13639
13653
 
@@ -13711,26 +13725,14 @@ WebsocketImplementation={
13711
13725
  // DBG
13712
13726
  lognow("INFO : (CLIENT-BROWSER) SETTING UP RECEIVE for :",channelName);
13713
13727
 
13714
- const doOnMessage=(message)=>{
13728
+ const doOnMessage=(eventOrMessage)=>{
13715
13729
 
13716
- // // DBG
13717
- // lognow("!!! RECEIVED : message",message);
13718
13730
 
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
-
13731
+ const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
13732
+
13733
+ ////
13734
+ // DBG
13735
+ lognow(" CLIENT-BROWSER RECEIVED 2:",dataWrapped);
13734
13736
 
13735
13737
 
13736
13738
  // 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.163",
3
+ "version": "0.0.166",
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)",