Class: Startback::Websocket::Hub::App
- Defined in:
- lib/startback/websocket/hub/app.rb
Overview
The Hub is a very opinionated websocket protocol based on room and subscriptions, allowing users to subscribe to rooms etc etc… # TODO
Direct Known Subclasses
Constant Summary
Constants inherited from App
Instance Method Summary collapse
-
#initialize(context, rooms, handler) ⇒ App
constructor
A new instance of App.
- #on_message(event, ws, env) ⇒ Object
- #room(name) ⇒ Object
Methods inherited from App
#broadcast, #call, #on_close, #on_error, #on_open
Constructor Details
#initialize(context, rooms, handler) ⇒ App
Returns a new instance of App.
11 12 13 14 15 |
# File 'lib/startback/websocket/hub/app.rb', line 11 def initialize(context, rooms, handler) super(context) @handler = handler @rooms = rooms end |
Instance Method Details
#on_message(event, ws, env) ⇒ Object
21 22 23 |
# File 'lib/startback/websocket/hub/app.rb', line 21 def (event, ws, env) @handler.call(Message.new(event.data, ws), ws, env) end |
#room(name) ⇒ Object
17 18 19 |
# File 'lib/startback/websocket/hub/app.rb', line 17 def room(name) @rooms[name] end |