Module: Rage::Cable
- Defined in:
- lib/rage/cable/cable.rb
Defined Under Namespace
Modules: Protocol Classes: Channel, Connection, Router, WebSocketConnection
Class Method Summary collapse
-
.application ⇒ Object
Create a new Cable application.
-
.broadcast(stream, data) ⇒ Object
Broadcast data directly to a named stream.
Class Method Details
.application ⇒ Object
Create a new Cable application.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rage/cable/cable.rb', line 10 def self.application protocol = Rage.config.cable.protocol protocol.init(__router) handler = __build_handler(protocol) accept_response = [0, protocol.protocol_definition, []] application = ->(env) do if env["rack.upgrade?"] == :websocket env["rack.upgrade"] = handler accept_response else [426, { "Connection" => "Upgrade", "Upgrade" => "websocket" }, []] end end Rage.with_middlewares(application, Rage.config.cable.middlewares) end |