Move SIGINT listener to connect function to avoid socket does not exist errors
Add conditional to disconnect peeringmerge-requests/1/head
parent
9076b1817b
commit
297aeb3d4a
|
@ -157,7 +157,7 @@ async function init(satyr: any, port: number, ircconf: any){
|
||||||
if(ircconf.enable) irc.part(socket.nick, rooms[i]);
|
if(ircconf.enable) irc.part(socket.nick, rooms[i]);
|
||||||
io.to(rooms[i]).emit('ALERT', socket.nick+' disconnected');
|
io.to(rooms[i]).emit('ALERT', socket.nick+' disconnected');
|
||||||
}
|
}
|
||||||
irc.unregisterUser(socket.nick);
|
if(ircconf.enable) irc.unregisterUser(socket.nick);
|
||||||
store.rm(socket.nick);
|
store.rm(socket.nick);
|
||||||
});
|
});
|
||||||
socket.on('NICK', async (data) => {
|
socket.on('NICK', async (data) => {
|
||||||
|
|
|
@ -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) => {
|
module.exports.connect = conf => new Promise((resolve, reject) => {
|
||||||
emitter.once('ping', resolve)
|
emitter.once('ping', resolve)
|
||||||
config = conf
|
config = conf
|
||||||
socket.connect(config.port)
|
socket.connect(config.port)
|
||||||
|
process.on('SIGINT', () => {
|
||||||
|
socket.write('QUIT\r\n')
|
||||||
|
process.exit()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
module.exports.events = emitter
|
module.exports.events = emitter
|
||||||
|
|
||||||
|
|
Reference in New Issue