Merge pull request #200 from shocknet/socket-ping-canary
socket ping canary
This commit is contained in:
commit
e6b2d0f896
1 changed files with 14 additions and 0 deletions
|
|
@ -5,6 +5,18 @@ const logger = require('winston')
|
||||||
const Encryption = require('../utils/encryptionStore')
|
const Encryption = require('../utils/encryptionStore')
|
||||||
const LightningServices = require('../utils/lightningServices')
|
const LightningServices = require('../utils/lightningServices')
|
||||||
|
|
||||||
|
const onPing = (socket, subID) => {
|
||||||
|
logger.warn('Subscribing to pings socket...' + subID)
|
||||||
|
|
||||||
|
const intervalID = setInterval(() => {
|
||||||
|
socket.emit('shockping')
|
||||||
|
}, 3000)
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearInterval(intervalID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = (
|
module.exports = (
|
||||||
/** @type {import('socket.io').Server} */
|
/** @type {import('socket.io').Server} */
|
||||||
io
|
io
|
||||||
|
|
@ -286,10 +298,12 @@ module.exports = (
|
||||||
logger.info('[LND] New LND Socket created:' + isNotifications + subID)
|
logger.info('[LND] New LND Socket created:' + isNotifications + subID)
|
||||||
const cancelInvoiceStream = onNewInvoice(socket, subID)
|
const cancelInvoiceStream = onNewInvoice(socket, subID)
|
||||||
const cancelTransactionStream = onNewTransaction(socket, subID)
|
const cancelTransactionStream = onNewTransaction(socket, subID)
|
||||||
|
const cancelPingStream = onPing(socket, subID)
|
||||||
socket.on('disconnect', () => {
|
socket.on('disconnect', () => {
|
||||||
logger.info('LND socket disconnected:' + isNotifications + subID)
|
logger.info('LND socket disconnected:' + isNotifications + subID)
|
||||||
cancelInvoiceStream()
|
cancelInvoiceStream()
|
||||||
cancelTransactionStream()
|
cancelTransactionStream()
|
||||||
|
cancelPingStream()
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue