Class: Tep::WebSocket::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/tep/websocket/driver.rb

Overview

Base class for event handlers. Subclass + override ‘handle_event(event)`. The Driver stores one Handler instance per event type and dispatches via `@h_message.handle_event(evt)`. The explicit-Handler shape (vs faye’s block-based ‘driver.on(:msg) { … }`) is chosen because it stays compatible with future Fiber.storage per-connection state plumbing without re-typing the callback boundary.

‘req` is set at WS upgrade time by the route handler the translator emits, giving on_X handler bodies access to the request that initiated the connection (req.identity, req.session, headers, …). It stays the same across every event on the connection – there’s no per-frame “request”.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHandler

Returns a new instance of Handler.



160
161
162
# File 'lib/tep/websocket/driver.rb', line 160

def initialize
  @req = Tep::Request.new
end

Instance Attribute Details

#reqObject

Returns the value of attribute req.



158
159
160
# File 'lib/tep/websocket/driver.rb', line 158

def req
  @req
end

Instance Method Details

#handle_event(event) ⇒ Object



164
165
166
# File 'lib/tep/websocket/driver.rb', line 164

def handle_event(event)
  0
end