Class | FTW::WebSocket::Rack |
In: |
lib/ftw/websocket/rack.rb
lib/ftw/websocket/rack.rb |
Parent: | Object |
A websocket helper for Rack
An example with Sinatra:
get "/websocket/echo" do ws = FTW::WebSocket::Rack.new(env) stream(:keep_open) do |out| ws.each do |payload| # 'payload' is the text payload of a single websocket message # publish it back to the client ws.publish(payload) end end ws.rack_response end
Get the response Rack is expecting.
If this was a valid websocket request, it will return a response that completes the HTTP portion of the websocket handshake.
If this was an invalid websocket request, it will return a 400 status code and descriptions of what failed in the body of the response.
@return [number, hash, body]
Get the response Rack is expecting.
If this was a valid websocket request, it will return a response that completes the HTTP portion of the websocket handshake.
If this was an invalid websocket request, it will return a 400 status code and descriptions of what failed in the body of the response.
@return [number, hash, body]