Class: Jason::Broadcaster
- Inherits:
-
Object
- Object
- Jason::Broadcaster
- Defined in:
- lib/jason/broadcaster.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
Instance Method Summary collapse
- #broadcast(message) ⇒ Object
-
#initialize(channel) ⇒ Broadcaster
constructor
A new instance of Broadcaster.
- #pusher_channel_name ⇒ Object
Constructor Details
#initialize(channel) ⇒ Broadcaster
Returns a new instance of Broadcaster.
4 5 6 |
# File 'lib/jason/broadcaster.rb', line 4 def initialize(channel) @channel = channel end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
2 3 4 |
# File 'lib/jason/broadcaster.rb', line 2 def channel @channel end |
Instance Method Details
#broadcast(message) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/jason/broadcaster.rb', line 12 def broadcast() if Jason.transport_service == :action_cable ActionCable.server.broadcast(channel, ) elsif Jason.transport_service == :pusher $redis_jason.rpush("jason:outbound_message_queue", { channel: pusher_channel_name, name: 'changed', data: }.to_json) Jason::OutboundMessageQueueWorker.perform_async end end |
#pusher_channel_name ⇒ Object
8 9 10 |
# File 'lib/jason/broadcaster.rb', line 8 def pusher_channel_name "private-#{Jason.pusher_channel_prefix}-#{channel}" end |