Move SIGINT listener to connect function to avoid socket does not exist errors

Add conditional to disconnect peering
merge-requests/1/head
knotteye 2019-11-05 17:48:12 -06:00
parent 9076b1817b
commit 297aeb3d4a
2 changed files with 5 additions and 6 deletions

View File

@ -157,7 +157,7 @@ async function init(satyr: any, port: number, ircconf: any){
if(ircconf.enable) irc.part(socket.nick, rooms[i]);
io.to(rooms[i]).emit('ALERT', socket.nick+' disconnected');
}
irc.unregisterUser(socket.nick);
if(ircconf.enable) irc.unregisterUser(socket.nick);
store.rm(socket.nick);
});
socket.on('NICK', async (data) => {

View File

@ -141,15 +141,14 @@ socket.on('data', data => {
})
})
process.on('SIGINT', () => {
socket.write('QUIT\r\n')
process.exit()
})
module.exports.connect = conf => new Promise((resolve, reject) => {
emitter.once('ping', resolve)
config = conf
socket.connect(config.port)
process.on('SIGINT', () => {
socket.write('QUIT\r\n')
process.exit()
})
})
module.exports.events = emitter