Class: ActionCable::Server::Broadcasting::Broadcaster
- Inherits:
-
Object
- Object
- ActionCable::Server::Broadcasting::Broadcaster
- Defined in:
- lib/action_cable/server/broadcasting.rb
Instance Attribute Summary collapse
-
#broadcasting ⇒ Object
readonly
Returns the value of attribute broadcasting.
-
#coder ⇒ Object
readonly
Returns the value of attribute coder.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #broadcast(message) ⇒ Object
-
#initialize(server, broadcasting, coder:) ⇒ Broadcaster
constructor
A new instance of Broadcaster.
Constructor Details
#initialize(server, broadcasting, coder:) ⇒ Broadcaster
Returns a new instance of Broadcaster.
46 47 48 |
# File 'lib/action_cable/server/broadcasting.rb', line 46 def initialize(server, broadcasting, coder:) @server, @broadcasting, @coder = server, broadcasting, coder end |
Instance Attribute Details
#broadcasting ⇒ Object (readonly)
Returns the value of attribute broadcasting.
44 45 46 |
# File 'lib/action_cable/server/broadcasting.rb', line 44 def broadcasting @broadcasting end |
#coder ⇒ Object (readonly)
Returns the value of attribute coder.
44 45 46 |
# File 'lib/action_cable/server/broadcasting.rb', line 44 def coder @coder end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
44 45 46 |
# File 'lib/action_cable/server/broadcasting.rb', line 44 def server @server end |
Instance Method Details
#broadcast(message) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/action_cable/server/broadcasting.rb', line 50 def broadcast() server.logger.debug { "[ActionCable] Broadcasting to #{broadcasting}: #{.inspect.truncate(300)}" } payload = { broadcasting: broadcasting, message: , coder: coder } ActiveSupport::Notifications.instrument("broadcast.action_cable", payload) do encoded = coder ? coder.encode() : server.pubsub.broadcast broadcasting, encoded end end |