Class: Motion::Channel
- Inherits:
-
ActionCable::Channel::Base
- Object
- ActionCable::Channel::Base
- Motion::Channel
- Includes:
- ActionCableExtentions::DeclarativeNotifications, ActionCableExtentions::DeclarativeStreams, ActionCableExtentions::LogSuppression
- Defined in:
- lib/motion/channel.rb
Instance Attribute Summary collapse
-
#component_connection ⇒ Object
readonly
Returns the value of attribute component_connection.
Class Method Summary collapse
-
.action_methods ⇒ Object
Don’t use the ActionCable heuristic for deciding what actions can be called from JavaScript.
Instance Method Summary collapse
- #process_broadcast(broadcast, message) ⇒ Object
- #process_motion(data) ⇒ Object
- #process_periodic_timer(timer) ⇒ Object
- #subscribed ⇒ Object
- #unsubscribed ⇒ Object
Methods included from ActionCableExtentions::LogSuppression
Methods included from ActionCableExtentions::DeclarativeStreams
#declarative_stream_target, #initialize, #stop_all_streams, #streaming_from
Methods included from ActionCableExtentions::Synchronization
#initialize, #perform_action, #subscribe_to_channel, #synchronize_entrypoint!, #unsubscribe_from_channel
Methods included from ActionCableExtentions::DeclarativeNotifications
#declarative_notifications, #initialize, #periodically_notify
Instance Attribute Details
#component_connection ⇒ Object (readonly)
Returns the value of attribute component_connection.
23 24 25 |
# File 'lib/motion/channel.rb', line 23 def component_connection @component_connection end |
Class Method Details
.action_methods ⇒ Object
Don’t use the ActionCable heuristic for deciding what actions can be called from JavaScript. Instead, hard-code the list so we can make other methods public without worrying about them being called from JavaScript.
19 20 21 |
# File 'lib/motion/channel.rb', line 19 def self.action_methods ACTION_METHODS end |
Instance Method Details
#process_broadcast(broadcast, message) ⇒ Object
55 56 57 58 |
# File 'lib/motion/channel.rb', line 55 def process_broadcast(broadcast, ) component_connection.process_broadcast(broadcast, ) synchronize end |
#process_motion(data) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/motion/channel.rb', line 48 def process_motion(data) motion, raw_event = data.values_at("name", "event") component_connection.process_motion(motion, Event.from_raw(raw_event)) synchronize end |
#process_periodic_timer(timer) ⇒ Object
60 61 62 63 |
# File 'lib/motion/channel.rb', line 60 def process_periodic_timer(timer) component_connection.process_periodic_timer(timer) synchronize end |
#subscribed ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/motion/channel.rb', line 25 def subscribed state, client_version = params.values_at("state", "version") if Gem::Version.new(Motion::VERSION) < Gem::Version.new(client_version) raise IncompatibleClientError.new(Motion::VERSION, client_version) end @component_connection = ComponentConnection.from_state(state, log_helper: log_helper) synchronize rescue => error reject handle_error(error, "connecting a component") end |
#unsubscribed ⇒ Object
42 43 44 45 46 |
# File 'lib/motion/channel.rb', line 42 def unsubscribed component_connection&.close @component_connection = nil end |