Merge pull request #776 from amyspark/fix-streaming-listeners

Keep an error listener after stopping socket
This commit is contained in:
AkiraFukushima 2018-12-09 17:10:51 +09:00 committed by GitHub
commit 9bb1198dbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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')
} }
} }