aotrautils 0.0.165 → 0.0.168

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:32:32)»*/
3
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (17/07/2022-14:50:24)»*/
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:32:32)»*/
4831
+ /*utils CLIENT library associated with aotra version : «1.0.0.000 (17/07/2022-14:50:24)»*/
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:32:32)»*/
11681
+ /*utils GEOMETRY library associated with aotra version : «1.0.0.000 (17/07/2022-14:50:24)»*/
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:32:32)»*/
12887
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (17/07/2022-14:50:24)»*/
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,27 +13251,13 @@ 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
-
13238
- ////
13239
- // DBG
13240
- lognow(" SERVER RECEIVED 1:",message);
13241
-
13242
-
13243
- let dataWrapped=message;
13244
- try{
13245
- dataWrapped=(WebsocketImplementation.useFlatStrings || isString(message)?JSON.parse(message):message);
13246
- }catch(error1){
13247
- // TRACE
13248
- lognow(`ERROR : Failed to parse JSON for string «${dataWrapped}»`,error1);
13249
- dataWrapped=(isString(message)?message:JSON.stringify(message));
13250
- }
13251
-
13252
-
13260
+ const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
13253
13261
  ////
13254
13262
  // DBG
13255
13263
  lognow(" SERVER RECEIVED 2:",dataWrapped);
@@ -13479,7 +13487,6 @@ WebsocketImplementation={
13479
13487
  nodeServerInstance.receive("protocol",(message, clientSocket)=>{
13480
13488
 
13481
13489
  if(message.type!=="joinRoom" || !clientSocket) return;
13482
-
13483
13490
  nodeServerInstance.addToRoom(clientSocket, message.clientRoomTag);
13484
13491
 
13485
13492
  });
@@ -13566,13 +13573,13 @@ WebsocketImplementation={
13566
13573
  clientsRoomsTag:clientsRoomsTag,
13567
13574
  execute:(clientSocketParam)=>{
13568
13575
 
13569
- const doOnMessage=(message)=>{
13576
+ const doOnMessage=(eventOrMessage)=>{
13570
13577
 
13571
13578
  // dataWrapped=JSON.parse(dataWrapped);
13572
13579
  // dataWrapped=getAt(dataWrapped,0);// We get the root element
13573
-
13574
- const dataWrapped=(WebsocketImplementation.useFlatStrings?JSON.parse(message):message);
13580
+ // const dataWrapped=(WebsocketImplementation.useFlatStrings?JSON.parse(eventOrMessage):eventOrMessage);
13575
13581
 
13582
+ const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
13576
13583
 
13577
13584
  // Channel information is stored in exchanged data :
13578
13585
  if(dataWrapped.channelName && dataWrapped.channelName!==channelName) return;
@@ -13642,9 +13649,7 @@ WebsocketImplementation={
13642
13649
  join:(clientRoomTag)=>{
13643
13650
  // Join room client part protocol :
13644
13651
  const message={type:"joinRoom",clientRoomTag:clientRoomTag};
13645
-
13646
13652
  nodeClientInstance.send("protocol",message);
13647
-
13648
13653
  },
13649
13654
 
13650
13655
 
@@ -13722,26 +13727,14 @@ WebsocketImplementation={
13722
13727
  // DBG
13723
13728
  lognow("INFO : (CLIENT-BROWSER) SETTING UP RECEIVE for :",channelName);
13724
13729
 
13725
- const doOnMessage=(message)=>{
13730
+ const doOnMessage=(eventOrMessage)=>{
13726
13731
 
13727
- // // DBG
13728
- // lognow("!!! RECEIVED : message",message);
13729
13732
 
13730
- // OLD : let dataWrapped=JSON.parse(event.data);
13731
- // const dataWrapped=JSON.parse(message);
13732
- // dataWrapped=getAt(dataWrapped,0);// We get the root element
13733
-
13734
-
13735
- let dataWrapped=message;
13736
- try{
13737
- dataWrapped=(WebsocketImplementation.useFlatStrings || isString(message)?JSON.parse(message):message);
13738
- }catch(error1){
13739
- // TRACE
13740
- lognow(`ERROR : Failed to parse JSON for string «${dataWrapped}»`,error1);
13741
- dataWrapped=(isString(message)?message:JSON.stringify(message));
13742
- }
13743
-
13744
-
13733
+ const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
13734
+
13735
+ ////
13736
+ // DBG
13737
+ lognow(" CLIENT-BROWSER RECEIVED 2:",dataWrapped);
13745
13738
 
13746
13739
 
13747
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.165",
3
+ "version": "0.0.168",
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)",