aotrautils 0.0.165 → 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:32:32)»*/
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:32:32)»*/
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:32:32)»*/
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:32:32)»*/
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,27 +13249,13 @@ 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
-
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
-
13258
+ const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
13253
13259
  ////
13254
13260
  // DBG
13255
13261
  lognow(" SERVER RECEIVED 2:",dataWrapped);
@@ -13479,7 +13485,6 @@ WebsocketImplementation={
13479
13485
  nodeServerInstance.receive("protocol",(message, clientSocket)=>{
13480
13486
 
13481
13487
  if(message.type!=="joinRoom" || !clientSocket) return;
13482
-
13483
13488
  nodeServerInstance.addToRoom(clientSocket, message.clientRoomTag);
13484
13489
 
13485
13490
  });
@@ -13566,13 +13571,13 @@ WebsocketImplementation={
13566
13571
  clientsRoomsTag:clientsRoomsTag,
13567
13572
  execute:(clientSocketParam)=>{
13568
13573
 
13569
- const doOnMessage=(message)=>{
13574
+ const doOnMessage=(eventOrMessage)=>{
13570
13575
 
13571
13576
  // dataWrapped=JSON.parse(dataWrapped);
13572
13577
  // dataWrapped=getAt(dataWrapped,0);// We get the root element
13573
-
13574
- const dataWrapped=(WebsocketImplementation.useFlatStrings?JSON.parse(message):message);
13578
+ // const dataWrapped=(WebsocketImplementation.useFlatStrings?JSON.parse(eventOrMessage):eventOrMessage);
13575
13579
 
13580
+ const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
13576
13581
 
13577
13582
  // Channel information is stored in exchanged data :
13578
13583
  if(dataWrapped.channelName && dataWrapped.channelName!==channelName) return;
@@ -13642,9 +13647,7 @@ WebsocketImplementation={
13642
13647
  join:(clientRoomTag)=>{
13643
13648
  // Join room client part protocol :
13644
13649
  const message={type:"joinRoom",clientRoomTag:clientRoomTag};
13645
-
13646
13650
  nodeClientInstance.send("protocol",message);
13647
-
13648
13651
  },
13649
13652
 
13650
13653
 
@@ -13722,26 +13725,14 @@ WebsocketImplementation={
13722
13725
  // DBG
13723
13726
  lognow("INFO : (CLIENT-BROWSER) SETTING UP RECEIVE for :",channelName);
13724
13727
 
13725
- const doOnMessage=(message)=>{
13728
+ const doOnMessage=(eventOrMessage)=>{
13726
13729
 
13727
- // // DBG
13728
- // lognow("!!! RECEIVED : message",message);
13729
13730
 
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
-
13731
+ const dataWrapped=WebsocketImplementation.getMessageDataBothImplementations(eventOrMessage);
13732
+
13733
+ ////
13734
+ // DBG
13735
+ lognow(" CLIENT-BROWSER RECEIVED 2:",dataWrapped);
13745
13736
 
13746
13737
 
13747
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.165",
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)",