@jcbuisson/express-x 1.6.8 → 1.6.10
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 +1 -1
- package/src/server.mjs +10 -6
package/package.json
CHANGED
package/src/server.mjs
CHANGED
|
@@ -360,14 +360,18 @@ 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
|
-
|
|
370
|
-
io.emit('cnx-transfer-ack', toConnection)
|
|
374
|
+
socket.emit('cnx-transfer-ack', toConnection)
|
|
371
375
|
})
|
|
372
376
|
|
|
373
377
|
/*
|
|
@@ -397,25 +401,25 @@ export function expressX(prisma, options = {}) {
|
|
|
397
401
|
})
|
|
398
402
|
} catch(err) {
|
|
399
403
|
app.log('error', err.toString())
|
|
400
|
-
|
|
404
|
+
socket.emit('client-response', {
|
|
401
405
|
uid,
|
|
402
406
|
error: err.toString(),
|
|
403
407
|
})
|
|
404
408
|
}
|
|
405
409
|
} else {
|
|
406
|
-
|
|
410
|
+
socket.emit('client-response', {
|
|
407
411
|
uid,
|
|
408
412
|
error: `there is no method named '${action}' for service '${name}'`,
|
|
409
413
|
})
|
|
410
414
|
}
|
|
411
415
|
} catch(error) {
|
|
412
|
-
|
|
416
|
+
socket.emit('client-response', {
|
|
413
417
|
uid,
|
|
414
418
|
error,
|
|
415
419
|
})
|
|
416
420
|
}
|
|
417
421
|
} else {
|
|
418
|
-
|
|
422
|
+
socket.emit('client-response', {
|
|
419
423
|
uid,
|
|
420
424
|
error: `there is no service named '${name}'`,
|
|
421
425
|
})
|