Module: Skinny::Helpers
- Defined in:
- lib/skinny.rb
Instance Method Summary collapse
- #websocket(options = {}, &block) ⇒ Object
- #websocket!(options = {}, &block) ⇒ Object
- #websocket? ⇒ Boolean
Instance Method Details
#websocket(options = {}, &block) ⇒ Object
439 440 441 442 443 444 445 |
# File 'lib/skinny.rb', line 439 def websocket ={}, &block env[SKINNY_WEBSOCKET] ||= begin raise RuntimerError, "Not a WebSocket request" unless websocket? [:on_message] = block if block_given? Websocket.from_env(env, ) end end |
#websocket!(options = {}, &block) ⇒ Object
447 448 449 |
# File 'lib/skinny.rb', line 447 def websocket! ={}, &block websocket(, &block).start! end |
#websocket? ⇒ Boolean
435 436 437 |
# File 'lib/skinny.rb', line 435 def websocket? env[CONNECTION] =~ UPGRADE_REGEXP && env[UPGRADE] =~ WEBSOCKET_REGEXP end |