Module: DrunkMonkey::Transport
- Defined in:
- lib/drunkmonkey/transport.rb
Defined Under Namespace
Classes: Base, Comet, HijackAPINotFoundError, WebSocket
Class Method Summary collapse
- .call(env, options = {}) ⇒ Object
-
.websocket?(env) ⇒ Boolean
Taken from github.com/simulacre/sinatra-websocket/ Originally taken from skinny github.com/sj26/skinny.
Class Method Details
.call(env, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/drunkmonkey/transport.rb', line 13 def self.call env, = {} request = Rack::Request.new(env) if websocket? env WebSocket.resume request, [500,{},[]] else body = Comet.resume request, [200,{},[body]] end end |
.websocket?(env) ⇒ Boolean
Taken from github.com/simulacre/sinatra-websocket/ Originally taken from skinny github.com/sj26/skinny
7 8 9 10 11 |
# File 'lib/drunkmonkey/transport.rb', line 7 def self.websocket? env env['HTTP_CONNECTION'] && env['HTTP_UPGRADE'] && env['HTTP_CONNECTION'].split(',').map(&:strip).map(&:downcase).include?('upgrade') && env['HTTP_UPGRADE'].downcase == 'websocket' end |