Module: Blade::Server
Constant Summary collapse
- WEBSOCKET_PATH =
"/blade/websocket"
Instance Method Summary collapse
- #client ⇒ Object
- #host ⇒ Object
- #publish(channel, message) ⇒ Object
- #start ⇒ Object
- #subscribe(channel) ⇒ Object
- #websocket_url(path = "") ⇒ Object
Methods included from Component
Instance Method Details
#client ⇒ Object
24 25 26 |
# File 'lib/blade/server.rb', line 24 def client @client ||= Faye::Client.new(websocket_url) end |
#host ⇒ Object
16 17 18 |
# File 'lib/blade/server.rb', line 16 def host Thin::Server::DEFAULT_HOST end |
#publish(channel, message) ⇒ Object
34 35 36 |
# File 'lib/blade/server.rb', line 34 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(host, Blade.config.port, app, signals: false) end |
#subscribe(channel) ⇒ Object
28 29 30 31 32 |
# File 'lib/blade/server.rb', line 28 def subscribe(channel) client.subscribe(channel) do || yield .with_indifferent_access end end |
#websocket_url(path = "") ⇒ Object
20 21 22 |
# File 'lib/blade/server.rb', line 20 def websocket_url(path = "") Blade.url(WEBSOCKET_PATH + path) end |