Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This example is compatible with [this version of a small Rails app with Action C


The available hooks to tie in to are:
- `disconnected {}`
- `disconnected { |code, reason| }`
Copy link
Owner

Choose a reason for hiding this comment

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

it's been a while for me, but where would someone find out what possible codes and reasons could be passed here?

Copy link
Author

Choose a reason for hiding this comment

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

I have no idea! The last one I had was reason being AuthError, I don't remember the code.

I guess you can find it from the ActionCable protocol specification, but Is that important for this PR?

Copy link
Owner

Choose a reason for hiding this comment

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

nah, thanks! It's just been ages since I've worked with Rails' things

Copy link
Author

Choose a reason for hiding this comment

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

👍

- `connected {}`
- `subscribed {}`
- `rejected {}`
Expand Down
10 changes: 4 additions & 6 deletions lib/action_cable_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def connect!(headers = {}, tls = {})
# - pong - sends a pong
@_websocket_client = WebSocket::EventMachine::Client.connect(uri: @_uri, headers: headers, tls: tls)

@_websocket_client.onclose do
@_websocket_client.onclose do |code, reason|
self._subscribed = false
_disconnected_callback&.call
_disconnected_callback&.call(code, reason)
end
end

Expand Down Expand Up @@ -152,10 +152,8 @@ def subscribed?
# client.disconnected do
# # cleanup after the server disconnects from the client
# end
def disconnected
self._disconnected_callback = proc do
yield
end
def disconnected(&block)
self._disconnected_callback = block
end

def pinged(&block)
Expand Down