-
Notifications
You must be signed in to change notification settings - Fork 24
WebSockets support #4
Comments
I'm interested in the answer to this question. I feel like it's nice if the API could hook into the middleware stack. If I have things like authentication, or some sort of header checking etc. it would be nice to be able to just slot a websocket request in there. Feels like maybe Rack needs to have a notion of a 'connection' handler. The http1.x handler could roughly be thought of as def handler(request)
[status, headers, body] = middleware.first.call(request)
end An http 'connection' handler might look like... def handler(connection)
request = HTTPRequest.new(connection)
[status, headers, body] = middleware.first.call(request)
deliver_response status, headers, body
end A websocket 'connection' handler would maybe look a bit more like... def handler(connection)
socket = WebSocketRequest.new(connection)
[status, headers, body] = websocket_middleware.first.call(request)
if status > 299
deliver_response status, headers, body
else
socket.accept
end
end The WebSocketRequest class or subclass could be responsible for dealing with messages Could allow for a new top-level configuration block in .ru files, something like.. protocol 'http' do
use AuthenticationMiddlware
end
protocol 'websocket' do
use AuthenticationMiddlware
end After trying that I wanted to type out... protocol 'websocket' do
handshake do
use AuthenticationMiddleware
end
map '/git' do
run WebsocketGitPackUploadHandler
end
map '/documents' do
use StreamingJSONParser
use StreamingXMLParser
use StreamingYAMLParser
run DocumentAPI
end
end Could very well be 3am nonsense, but I would like to see Rack figure out websockets. |
+1 any progress on this? |
What would be wrong with doing something like this? https://github.com/faye/faye-websocket-ruby
|
Then, kill this line and pass it along like usual: reel-rack/lib/reel/rack/server.rb Line 27 in 5c58e3c
Obviously, we'd want to use the |
There's a PR into Reel to use the |
The previous Rack adapter for Reel supported WebSockets through the
reel.websocket
environment variable.Should
reel-rack
support WebSockets? Is a Rack environment variable the way to go? Or should there be a more direct API, possibly one that can bypass all of Rack's abstraction layers and just hand your program a WebSocket independently of Rack?I think it'd be neat if
reel-rack
had a more direct WebSockets API. Maybe we can figure out one that becomes a standard for all Rack web servers support.The text was updated successfully, but these errors were encountered: