@jcbuisson/express-x-client 2.2.0 → 2.2.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcbuisson/express-x-client",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "type": "module",
5
5
  "description": "Client library for ExpressX framework",
6
6
  "main": "src/index.mjs",
package/src/index.mjs CHANGED
@@ -22,21 +22,21 @@ export default function expressXClient(socket, options={}) {
22
22
  let errorListeners = []
23
23
 
24
24
  socket.on("connect", async () => {
25
- console.log("socket connected", socket.id)
25
+ if (options.debug) console.log("socket connected", socket.id)
26
26
  for (const func of connectListeners) {
27
27
  func(socket)
28
28
  }
29
29
  })
30
30
 
31
31
  socket.on("connect_error", async (err) => {
32
- console.log("socket connection error", socket.id)
32
+ if (options.debug) console.log("socket connection error", socket.id)
33
33
  for (const func of errorListeners) {
34
34
  func(socket)
35
35
  }
36
36
  })
37
37
 
38
38
  socket.on("disconnect", async () => {
39
- console.log("socket disconnected", socket.id)
39
+ if (options.debug) console.log("socket disconnected", socket.id)
40
40
  for (const func of disconnectListeners) {
41
41
  func(socket)
42
42
  }
@@ -91,10 +91,12 @@ export default function expressXClient(socket, options={}) {
91
91
  const promise = new Promise((resolve, reject) => {
92
92
  waitingPromisesByUid[uid] = [resolve, reject]
93
93
  // a timeout may also reject the promise
94
- setTimeout(() => {
95
- delete waitingPromisesByUid[uid]
96
- reject(`Error: timeout on service '${name}', action '${action}', args: ${JSON.stringify(args)}`)
97
- }, serviceOptions.timeout)
94
+ if (serviceOptions.timeout && !serviceOptions.volatile) {
95
+ setTimeout(() => {
96
+ delete waitingPromisesByUid[uid]
97
+ reject(`Error: timeout on service '${name}', action '${action}', args: ${JSON.stringify(args)}`)
98
+ }, serviceOptions.timeout)
99
+ }
98
100
  })
99
101
  // send request to server through websocket
100
102
  if (options.debug) console.log('client-request', uid, name, action, args)
@@ -139,14 +141,12 @@ export default function expressXClient(socket, options={}) {
139
141
  if (options.debug) console.log('app-event', type, value)
140
142
  if (!type2appHandler[type]) type2appHandler[type] = {}
141
143
  const handler = type2appHandler[type]
142
- console.log('handler', handler)
143
144
  if (handler) handler(value)
144
145
  })
145
146
 
146
147
  // add a handler for application-wide events
147
148
  function on(type, handler) {
148
149
  type2appHandler[type] = handler
149
- console.log('type2appHandler[type]', type2appHandler[type])
150
150
  }
151
151
 
152
152
  return {
@@ -1,18 +0,0 @@
1
- {
2
- // Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
3
- // Pointez pour afficher la description des attributs existants.
4
- // Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "test",
11
- "skipFiles": [
12
- "<node_internals>/**"
13
- ],
14
- "cwd": "${workspaceFolder}",
15
- "program": "${workspaceFolder}/test/index.test.js"
16
- }
17
- ]
18
- }