Class: Hyperloop::ActionCableChannel
- Inherits:
-
ApplicationCable::Channel
- Object
- ActionCable::Channel::Base
- ApplicationCable::Channel
- Hyperloop::ActionCableChannel
- Defined in:
- lib/hyper-operation/transport/action_cable.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.subscriptions ⇒ Object
9 10 11 |
# File 'lib/hyper-operation/transport/action_cable.rb', line 9 def subscriptions @subscriptions ||= Hash.new { |h, k| h[k] = 0 } end |
Instance Method Details
#dec_subscription ⇒ Object
19 20 21 22 |
# File 'lib/hyper-operation/transport/action_cable.rb', line 19 def dec_subscription self.class.subscriptions[params[:hyperloop_channel]] = self.class.subscriptions[params[:hyperloop_channel]] - 1 end |
#inc_subscription ⇒ Object
14 15 16 17 |
# File 'lib/hyper-operation/transport/action_cable.rb', line 14 def inc_subscription self.class.subscriptions[params[:hyperloop_channel]] = self.class.subscriptions[params[:hyperloop_channel]] + 1 end |
#subscribed ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/hyper-operation/transport/action_cable.rb', line 24 def subscribed session_id = params["client_id"] = Hyperloop.(params["salt"], params["hyperloop_channel"], session_id) if params["authorization"] == inc_subscription stream_from "hyperloop-#{params[:hyperloop_channel]}" else reject end end |
#unsubscribed ⇒ Object
35 36 37 |
# File 'lib/hyper-operation/transport/action_cable.rb', line 35 def unsubscribed Hyperloop::Connection.disconnect(params[:hyperloop_channel]) if dec_subscription == 0 end |