@jcbuisson/express-x 1.6.8 → 1.6.9

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/server.mjs +5 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcbuisson/express-x",
3
- "version": "1.6.8",
3
+ "version": "1.6.9",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "src/index.mjs",
package/src/server.mjs CHANGED
@@ -360,13 +360,17 @@ export function expressX(prisma, options = {}) {
360
360
  // handle connection data transfer caused by a disconnection/reconnection (page reload, network issue, etc.)
361
361
  socket.on('cnx-transfer', async ({ from, to }) => {
362
362
  app.log('verbose', `cnx-transfer from ${from} to ${to}`)
363
+ // copy connection data from 'from' to 'to'
363
364
  const fromConnection = await getConnection(from)
364
365
  if (!fromConnection) return
365
366
  const toConnection = await cloneConnection(to, fromConnection)
367
+ // associate socket to 'to'
366
368
  setSocket(to, socket)
369
+ // transfer timer from 'from' to 'to'
370
+ setTimer(to, getTimer(from))
371
+ // delete 'from'
367
372
  await deleteConnection(from)
368
373
  // send acknowledge to client
369
- // io.emit('cnx-transfer-ack', toConnection.data)
370
374
  io.emit('cnx-transfer-ack', toConnection)
371
375
  })
372
376