aotrautils-srv 0.0.74 → 0.0.77

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 SERVER library associated with aotra version : «1.0.0.000 (13/07/2022-02:19:46)»*/
3
+ /*utils SERVER library associated with aotra version : «1.0.0.000 (13/07/2022-09:28:37)»*/
4
4
  /*-----------------------------------------------------------------------------*/
5
5
 
6
6
 
@@ -30,6 +30,45 @@ if(typeof(window)==="undefined") window=global;
30
30
 
31
31
 
32
32
 
33
+ // OLD : socket.io :
34
+ // https://stackoverflow.com/questions/31156884/how-to-use-https-on-node-js-using-express-socket-io
35
+ // https://stackoverflow.com/questions/6599470/node-js-socket-io-with-ssl
36
+ // https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
37
+
38
+ if(typeof(socketIO)==="undefined"){
39
+ // TRACE
40
+ lognow("«socket.io» SERVER library not called yet, calling it now.");
41
+ socketIO=require("socket.io");
42
+ // TRACE
43
+ lognow("«socket.io» SERVER library called:",socketIO);
44
+
45
+ }
46
+ if(typeof(socketIO)==="undefined"){
47
+ // Exception
48
+ lognow("ERROR : «socket.io» SERVER library not found. Cannot launch nodejs server. Aborting.");
49
+ }
50
+
51
+ // NEW : ws :
52
+ // https://github.com/websockets/ws#installing
53
+ // https://github.com/websockets/ws/blob/master/doc/ws.md#event-message
54
+ // ON BROWSER SIDE : Native Websockets :
55
+ // https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
56
+ // https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications
57
+ if(typeof(WebSocket)==="undefined"){
58
+ WebSocket=require("ws");
59
+ // TRACE
60
+ console.log("«ws» SERVER library not called yet, calling it now.");
61
+ }
62
+ if(typeof(WebSocket)==="undefined"){
63
+ // TRACE
64
+ console.log("ERROR : «ws» SERVER library not found. Cannot launch nodejs server. Aborting.");
65
+ }
66
+
67
+
68
+
69
+
70
+
71
+
33
72
  // =================================================================================
34
73
  // NODEJS UTILS
35
74
 
@@ -216,31 +255,16 @@ WebsocketImplementation={
216
255
 
217
256
  WebsocketImplementation.isNodeContext=isNodeContext;
218
257
 
258
+ //const globalContext=(WebsocketImplementation.isNodeContext?global:window);
259
+
260
+
219
261
  // cf. https://socket.io/docs/v4/client-socket-instance/
220
262
  WebsocketImplementation.useSocketIOImplementation=useSocketIOImplementation;
221
263
 
222
264
  if(WebsocketImplementation.useSocketIOImplementation){
223
-
224
265
  // TRACE
225
266
  lognow("INFO : (SERVER/CLIENT) Using socket.io websocket implementation.");
226
267
 
227
- // OLD : socket.io :
228
- // https://stackoverflow.com/questions/31156884/how-to-use-https-on-node-js-using-express-socket-io
229
- // https://stackoverflow.com/questions/6599470/node-js-socket-io-with-ssl
230
- // https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
231
-
232
- if(typeof(socketIO)==="undefined"){
233
- // TRACE
234
- lognow("«socket.io» SERVER library not called yet, calling it now.");
235
- socketIO=require("socket.io");
236
- // TRACE
237
- lognow("«socket.io» SERVER library called:",socketIO);
238
-
239
- }
240
- if(typeof(socketIO)==="undefined"){
241
- // Exception
242
- throw "ERROR : «socket.io» SERVER library not found. Cannot launch nodejs server. Aborting.";
243
- }
244
268
  }else{
245
269
  // TRACE
246
270
  lognow("INFO : (SERVER/CLIENT) Using native websocket implementation.");
@@ -249,23 +273,7 @@ WebsocketImplementation={
249
273
 
250
274
  // *********************************************************************************
251
275
 
252
- // NEW : ws :
253
- // https://github.com/websockets/ws#installing
254
- // https://github.com/websockets/ws/blob/master/doc/ws.md#event-message
255
- // ON BROWSER SIDE : Native Websockets :
256
- // https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
257
- // https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications
258
- if(typeof(WebSocket)==="undefined"){
259
- WebSocket=require("ws");
260
- // TRACE
261
- console.log("«ws» SERVER library not called yet, calling it now.");
262
- return WebsocketImplementation;
263
- }
264
- if(typeof(WebSocket)==="undefined"){
265
- // TRACE
266
- console.log("ERROR : «ws» SERVER library not found. Cannot launch nodejs server. Aborting.");
267
- return null;
268
- }
276
+
269
277
 
270
278
  return WebsocketImplementation;
271
279
  },
@@ -285,7 +293,7 @@ WebsocketImplementation={
285
293
  serverSocket=new WebSocket.Server({ "server":listenableServer });
286
294
  }else{
287
295
 
288
-
296
+
289
297
  // DBG
290
298
  console.log(">>>>>>>socketIO:",JSON.stringify(socketIO));
291
299
 
@@ -593,6 +601,8 @@ WebsocketImplementation={
593
601
  }else{
594
602
  // NOW : socket.io :
595
603
  //client on server-side:
604
+
605
+
596
606
  if(WebsocketImplementation.isNodeContext && typeof(socketIO)!=="undefined"){
597
607
  // // Node client :
598
608
  // connectToServer=function (serverURL, port, isSecure, timeout=10000){
@@ -1317,7 +1327,7 @@ function getListManager(config){
1317
1327
 
1318
1328
 
1319
1329
 
1320
- /*utils COMMONS library associated with aotra version : «1.0.0.000 (13/07/2022-02:19:46)»*/
1330
+ /*utils COMMONS library associated with aotra version : «1.0.0.000 (13/07/2022-09:28:37)»*/
1321
1331
  /*-----------------------------------------------------------------------------*/
1322
1332
 
1323
1333
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aotrautils-srv",
3
- "version": "0.0.74",
3
+ "version": "0.0.77",
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)",