Module: Sinatra::WebSocket
- Defined in:
- lib/sinatra/websocket.rb
Constant Summary collapse
- WEBSOCKET_OPTIONS =
[:protocol, :on_open, :on_start, :on_handshake, :on_message, :on_error, :on_finish, :on_close]
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.registered(base) ⇒ Object
6 7 8 |
# File 'lib/sinatra/websocket.rb', line 6 def self.registered base base.send :include, Skinny::Helpers end |
Instance Method Details
#websocket(path = '*', options = {}, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sinatra/websocket.rb', line 10 def websocket path='*', ={}, &block # No nice way to do this in core? = .select { |key, value| WEBSOCKET_OPTIONS.include? key } .reject! { |key, value| WEBSOCKET_OPTIONS.include? key } condition { websocket? } route 'GET', path, do websocket! .dup, &block throw :async end end |