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 = 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)
|
||||||
},
|
},
|
||||||
|
|
|
@ -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')
|
||||||
}
|
}
|
||||||
|
|
|
@ -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')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue