Class: WebsocketRails::ChannelManager
- Inherits:
-
Object
- Object
- WebsocketRails::ChannelManager
- Defined in:
- lib/websocket_rails/channel_manager.rb
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#filtered_channels ⇒ Object
readonly
Returns the value of attribute filtered_channels.
Instance Method Summary collapse
- #[](channel) ⇒ Object
- #channel_tokens ⇒ Object
-
#initialize ⇒ ChannelManager
constructor
A new instance of ChannelManager.
- #unsubscribe(connection) ⇒ Object
Constructor Details
#initialize ⇒ ChannelManager
Returns a new instance of ChannelManager.
29 30 31 32 |
# File 'lib/websocket_rails/channel_manager.rb', line 29 def initialize @channels = {}.with_indifferent_access @filtered_channels = {}.with_indifferent_access end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
27 28 29 |
# File 'lib/websocket_rails/channel_manager.rb', line 27 def channels @channels end |
#filtered_channels ⇒ Object (readonly)
Returns the value of attribute filtered_channels.
27 28 29 |
# File 'lib/websocket_rails/channel_manager.rb', line 27 def filtered_channels @filtered_channels end |
Instance Method Details
#[](channel) ⇒ Object
44 45 46 |
# File 'lib/websocket_rails/channel_manager.rb', line 44 def [](channel) @channels[channel] ||= Channel.new channel end |
#channel_tokens ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/websocket_rails/channel_manager.rb', line 34 def channel_tokens @channel_tokens ||= begin if WebsocketRails.synchronize? ::Redis::HashKey.new('websocket_rails.channel_tokens', Synchronization.redis) else {} end end end |
#unsubscribe(connection) ⇒ Object
48 49 50 51 52 |
# File 'lib/websocket_rails/channel_manager.rb', line 48 def unsubscribe(connection) @channels.each do |channel_name, channel| channel.unsubscribe(connection) end end |