From 9f184153d6c69ce77e660b9dcc0c86efc5b4cb01 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Sat, 7 Nov 2020 11:03:32 -0400 Subject: [PATCH] restore notifs serv socket ns --- src/sockets.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/sockets.js b/src/sockets.js index 52fb9bb2..e09da0be 100644 --- a/src/sockets.js +++ b/src/sockets.js @@ -257,6 +257,33 @@ module.exports = ( } } + io.of('default').on('connection', socket => { + logger.info(`io.onconnection`) + logger.info('socket.handshake', socket.handshake) + + const isLNDSocket = !!socket.handshake.query.IS_LND_SOCKET + const isNotificationsSocket = !!socket.handshake.query + .IS_NOTIFICATIONS_SOCKET + + if (!isLNDSocket) { + /** printing out the client who joined */ + logger.info('New socket client connected (id=' + socket.id + ').') + } + + if (isLNDSocket) { + const subID = Math.floor(Math.random() * 1000).toString() + const isNotifications = isNotificationsSocket ? 'notifications' : '' + logger.info('[LND] New LND Socket created:' + isNotifications + subID) + const cancelInvoiceStream = onNewInvoice(socket, subID) + const cancelTransactionStream = onNewTransaction(socket, subID) + socket.on('disconnect', () => { + logger.info('LND socket disconnected:' + isNotifications + subID) + cancelInvoiceStream() + cancelTransactionStream() + }) + } + }) + io.of('gun').on('connect', socket => { // TODO: off()