Module: Blade::Server
Constant Summary collapse
- WEBSOCKET_PATH =
"/blade/websocket"
Instance Method Summary collapse
- #client ⇒ Object
- #publish(channel, message) ⇒ Object
- #start ⇒ Object
- #subscribe(channel) ⇒ Object
- #websocket_url(path = "") ⇒ Object
Methods included from Component
Instance Method Details
#client ⇒ Object
20 21 22 |
# File 'lib/blade/server.rb', line 20 def client @client ||= Faye::Client.new(websocket_url) end |
#publish(channel, message) ⇒ Object
30 31 32 |
# File 'lib/blade/server.rb', line 30 def publish(channel, ) client.publish(channel, ) end |
#start ⇒ Object
10 11 12 13 14 |
# File 'lib/blade/server.rb', line 10 def start Faye::WebSocket.load_adapter("thin") Thin::Logging.silent = true Thin::Server.start("localhost", Blade.config.port, app, signals: false) end |
#subscribe(channel) ⇒ Object
24 25 26 27 28 |
# File 'lib/blade/server.rb', line 24 def subscribe(channel) client.subscribe(channel) do || yield .with_indifferent_access end end |
#websocket_url(path = "") ⇒ Object
16 17 18 |
# File 'lib/blade/server.rb', line 16 def websocket_url(path = "") Blade.url(WEBSOCKET_PATH + path) end |