Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send more info on disconnected event #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions lib/firehose/consumer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ class Consumer
@config.connected = origConnected
origConnected()

# origDisconnected = @config.disconnected
# @config.disconnected = =>
# deferred.reject()
# if origDisconnected
# @config.disconnected = origDisconnected
# origDisconnected()

deferred.promise()

Consumer.multiplexChannel = "channels@firehose"
Expand Down
2 changes: 1 addition & 1 deletion lib/firehose/long_poll_transport.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class LongPollTransport extends Transport

unless @_needToNotifyOfReconnect or @_stopRequestLoop
@_needToNotifyOfReconnect = true
@config.disconnected()
@config.disconnected(jqXhr, status, error)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What type is the event that's passed to this from the websocket versions? As I'd at least like the first parameter to be a similar type across them both, my guess that in this case error may match better as a first argument.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, make sure we can determine if it was long poll or web socket in the handler. If the event doesn't include something we can use (somewhat clearly) then I'd suggest another parameter of just long-poll or similar

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was on the fence about this. I think it's a bit different across transports, since this is the result from a rejected jQuery promise whereas the WebSockets one is a CloseEvent specific to WebSockets.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine switching to just the error object if you think that's better. Should we pass the transport type in all the events (connected, disconnected, failed, error)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, yes. Although as the other events already have some data passed in, it would be hard to define a standard way. Perhaps that change would be better waiting for a rewrite/refactor/v2 to standardize them.

unless @_stopRequestLoop
# Ping the server to make sure this isn't a network connectivity error
setTimeout @_ping, @_retryDelay + @_lagTime
Expand Down
4 changes: 2 additions & 2 deletions lib/firehose/transport.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Transport
_error: (event) =>
if @_succeeded
# Lets try to connect again with delay
@config.disconnected()
@config.disconnected event
@connect(@_retryDelay)
else @config.failed event

Expand All @@ -37,7 +37,7 @@ class Transport

# Default connection closed handler
_close: (event) =>
@config.disconnected()
@config.disconnected event

# Useful for reconnecting after any networking hiccups
getLastMessageSequence: =>
Expand Down
2 changes: 1 addition & 1 deletion lib/firehose/web_socket_transport.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class WebSocketTransport extends Transport
@_cleanUp()
if @_needToNotifyOfDisconnect
@_needToNotifyOfDisconnect = false
@config.disconnected()
@config.disconnected event
if @_succeeded
@connect @_retryDelay
else if @config.failed
Expand Down