diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/action_cable/server.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/action_cable/server.rb b/lib/action_cable/server.rb index 3c78ad5239..c7745e6b3c 100644 --- a/lib/action_cable/server.rb +++ b/lib/action_cable/server.rb @@ -24,6 +24,8 @@ module ActionCable end end + attr_reader :env + def initialize(env) @env = env end @@ -37,6 +39,7 @@ module ActionCable @websocket.on(:open) do |event| broadcast_ping_timestamp @ping_timer = EventMachine.add_periodic_timer(PING_INTERVAL) { broadcast_ping_timestamp } + worker_pool.async.invoke(self, :connect) if respond_to?(:connect) end @websocket.on(:message) do |event| @@ -85,6 +88,14 @@ module ActionCable self.class.worker_pool end + def request + @request ||= ActionDispatch::Request.new(env) + end + + def cookies + request.cookie_jar + end + private def broadcast_ping_timestamp broadcast({ identifier: '_ping', message: Time.now.to_i }.to_json) |