Keep an error listener after stopping socket

This commit is contained in:
L. E. Segovia 2018-12-07 14:20:05 +00:00
parent 70237baa8f
commit 7752230e09
No known key found for this signature in database
GPG Key ID: D5D1DC48B52B7AD5
3 changed files with 15 additions and 4 deletions

View File

@ -447,7 +447,7 @@ ipcMain.on('start-directmessages-streaming', (event, ac) => {
directMessagesStreaming = new StreamingManager(account) directMessagesStreaming = new StreamingManager(account)
directMessagesStreaming.start( directMessagesStreaming.start(
'direct', 'direct',
null, '',
(update) => { (update) => {
event.sender.send('update-start-directmessages-streaming', update) event.sender.send('update-start-directmessages-streaming', update)
}, },
@ -484,7 +484,7 @@ ipcMain.on('start-local-streaming', (event, ac) => {
localStreaming = new StreamingManager(account) localStreaming = new StreamingManager(account)
localStreaming.start( localStreaming.start(
'public/local', 'public/local',
null, '',
(update) => { (update) => {
event.sender.send('update-start-local-streaming', update) event.sender.send('update-start-local-streaming', update)
}, },
@ -521,7 +521,7 @@ ipcMain.on('start-public-streaming', (event, ac) => {
publicStreaming = new StreamingManager(account) publicStreaming = new StreamingManager(account)
publicStreaming.start( publicStreaming.start(
'public', 'public',
null, '',
(update) => { (update) => {
event.sender.send('update-start-public-streaming', update) event.sender.send('update-start-public-streaming', update)
}, },

View File

@ -56,6 +56,14 @@ export default class Streaming {
stop () { stop () {
if (this.listener) { if (this.listener) {
this.listener.removeAllListeners('connect')
this.listener.removeAllListeners('update')
this.listener.removeAllListeners('notification')
this.listener.removeAllListeners('error')
this.listener.removeAllListeners('parser-error')
this.listener.on('error', (e) => {
log.error(e)
})
this.listener.stop() this.listener.stop()
log.info('streaming stopped') log.info('streaming stopped')
} }

View File

@ -67,12 +67,15 @@ export default class WebSocket {
stop () { stop () {
if (this.listener) { if (this.listener) {
this.listener.stop()
this.listener.removeAllListeners('connect') this.listener.removeAllListeners('connect')
this.listener.removeAllListeners('update') this.listener.removeAllListeners('update')
this.listener.removeAllListeners('notification') this.listener.removeAllListeners('notification')
this.listener.removeAllListeners('error') this.listener.removeAllListeners('error')
this.listener.removeAllListeners('parser-error') this.listener.removeAllListeners('parser-error')
this.listener.on('error', (e) => {
log.error(e)
})
this.listener.stop()
log.info('streaming stopped') log.info('streaming stopped')
} }
} }