Merge pull request #776 from amyspark/fix-streaming-listeners
Keep an error listener after stopping socket
This commit is contained in:
commit
9bb1198dbb
|
@ -447,7 +447,7 @@ ipcMain.on('start-directmessages-streaming', (event, ac) => {
|
|||
directMessagesStreaming = new StreamingManager(account)
|
||||
directMessagesStreaming.start(
|
||||
'direct',
|
||||
null,
|
||||
'',
|
||||
(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.start(
|
||||
'public/local',
|
||||
null,
|
||||
'',
|
||||
(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.start(
|
||||
'public',
|
||||
null,
|
||||
'',
|
||||
(update) => {
|
||||
event.sender.send('update-start-public-streaming', update)
|
||||
},
|
||||
|
|
|
@ -56,6 +56,14 @@ export default class Streaming {
|
|||
|
||||
stop () {
|
||||
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()
|
||||
log.info('streaming stopped')
|
||||
}
|
||||
|
|
|
@ -67,12 +67,15 @@ export default class WebSocket {
|
|||
|
||||
stop () {
|
||||
if (this.listener) {
|
||||
this.listener.stop()
|
||||
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()
|
||||
log.info('streaming stopped')
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue