Class: ActionCable::SubscriptionAdapter::AnyCable
- Inherits:
-
Base
- Object
- Base
- ActionCable::SubscriptionAdapter::AnyCable
- Defined in:
- lib/action_cable/subscription_adapter/any_cable.rb
Overview
AnyCable subscription adapter delegates broadcasts to AnyCable
Constant Summary collapse
- ACTION_CABLE_SERVER_ERROR_MESSAGE =
<<~STR Looks like you are trying to connect to Rails Action Cable server, not an AnyCable one. Please make sure your client is configured to connect to AnyCable server. See https://docs.anycable.io/troubleshooting STR
Instance Method Summary collapse
- #broadcast(channel, payload, **options) ⇒ Object
-
#initialize ⇒ AnyCable
constructor
A new instance of AnyCable.
- #shutdown ⇒ Object
- #subscribe ⇒ Object
- #unsubscribe ⇒ Object
Constructor Details
#initialize ⇒ AnyCable
Returns a new instance of AnyCable.
18 19 |
# File 'lib/action_cable/subscription_adapter/any_cable.rb', line 18 def initialize(*) end |
Instance Method Details
#broadcast(channel, payload, **options) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/action_cable/subscription_adapter/any_cable.rb', line 21 def broadcast(channel, payload, **) .merge!(::AnyCable::Rails. || {}) to_others = .delete(:to_others) [:exclude_socket] ||= ::AnyCable::Rails.current_socket_id if to_others ::AnyCable.broadcast(channel, payload, **.compact) end |
#shutdown ⇒ Object
36 37 38 39 40 |
# File 'lib/action_cable/subscription_adapter/any_cable.rb', line 36 def shutdown # nothing to do # we only need this method for development, # 'cause code reloading triggers `server.restart` -> `pubsub.shutdown` end |
#subscribe ⇒ Object
28 29 30 |
# File 'lib/action_cable/subscription_adapter/any_cable.rb', line 28 def subscribe(*) raise NotImplementedError, ACTION_CABLE_SERVER_ERROR_MESSAGE end |
#unsubscribe ⇒ Object
32 33 34 |
# File 'lib/action_cable/subscription_adapter/any_cable.rb', line 32 def unsubscribe(*) raise NotImplementedError, ACTION_CABLE_SERVER_ERROR_MESSAGE end |