examples/websockets.rb in reel-0.4.0.pre vs examples/websockets.rb in reel-0.4.0.pre2

- old
+ new

@@ -46,15 +46,25 @@ super(host, port, &method(:on_connection)) end def on_connection(connection) while request = connection.request - case request - when Reel::Request - route_request connection, request - when Reel::WebSocket + if request.websocket? info "Received a WebSocket connection" - route_websocket request + + # We're going to hand off this connection to another actor (TimeClient) + # However, initially Reel::Connections are "attached" to the + # Reel::Server actor, meaning that the server manages the connection + # lifecycle (e.g. error handling) for us. + # + # If we want to hand this connection off to another actor, we first + # need to detach it from the Reel::Server + connection.detach + + route_websocket request.websocket + return + else + route_request connection, request end end end def route_request(connection, request)