From 6735ee0193506daa0f1f66f38553e626eadc930d Mon Sep 17 00:00:00 2001 From: Antonio Salazar Cardozo Date: Thu, 10 May 2018 22:09:04 -0400 Subject: [PATCH] Move connected event to post-flow-join The `connected` event was being emitted after the Flowdock connection was *initiated*, but that meant the event was dispatched before there was actually a live connection to work with. This meant sending messages on connect, for example, wouldn't work. The `connected` event is now correctly dispatched once the connection to Flowdock is fully established and authed, and all flows have been joined. --- src/flowdock.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/flowdock.coffee b/src/flowdock.coffee index bb8ca2d..1f35ecb 100644 --- a/src/flowdock.coffee +++ b/src/flowdock.coffee @@ -105,6 +105,7 @@ class Flowdock extends Adapter @stream.on 'connected', => @robot.logger.info('Flowdock: connected and streaming') @robot.logger.info('Flowdock: listening to flows:', (flow.name for flow in @joinedFlows()).join(', ')) + @emit 'connected' @stream.on 'clientError', (error) => @robot.logger.error('Flowdock: client error:', error) @stream.on 'disconnected', => @robot.logger.info('Flowdock: disconnected') @stream.on 'reconnecting', => @robot.logger.info('Flowdock: reconnecting') @@ -176,8 +177,6 @@ class Flowdock extends Adapter @fetchFlowsAndConnect() - @emit 'connected' - fetchFlowsAndConnect: -> @bot.flows (err, flows, res) => return if err?