remove old socket code

This commit is contained in:
Daniel Lugo 2020-09-28 14:23:33 -04:00
parent 3d965fe630
commit f184f7be94

View file

@ -1,5 +1,5 @@
/** @prettier */
// app/sockets.js
// @ts-check
const logger = require('winston')
const Encryption = require('../utils/encryptionStore')
@ -21,8 +21,6 @@ module.exports = (
/** @type {import('socket.io').Server} */
io
) => {
const Mediator = require('../services/gunDB/Mediator/index.js')
// This should be used for encrypting and emitting your data
const emitEncryptedEvent = ({ eventName, data, socket }) => {
try {
@ -260,38 +258,15 @@ module.exports = (
logger.info('socket.handshake', socket.handshake)
const isOneTimeUseSocket = !!socket.handshake.query.IS_GUN_AUTH
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 (isOneTimeUseSocket) {
logger.info('New socket is one time use')
socket.on('IS_GUN_AUTH', () => {
try {
const isGunAuth = Mediator.isAuthenticated()
socket.emit('IS_GUN_AUTH', {
ok: true,
msg: {
isGunAuth
},
origBody: {}
})
socket.disconnect()
} catch (err) {
socket.emit('IS_GUN_AUTH', {
ok: false,
msg: err.message,
origBody: {}
})
socket.disconnect()
}
})
} else {
if (isLNDSocket) {
const subID = Math.floor(Math.random() * 1000).toString()
const isNotifications = isNotificationsSocket ? 'notifications' : ''
@ -305,17 +280,6 @@ module.exports = (
cancelTransactionStream()
cancelPingStream()
})
return
}
logger.info('New socket is NOT one time use')
// this is where we create the websocket connection
// with the GunDB service.
Mediator.createMediator(socket)
/** listening if client has disconnected */
socket.on('disconnect', () => {
logger.info('client disconnected (id=' + socket.id + ').')
})
}
})