You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I started to work on this and got stuck. The expected behavior isn't 100% obvious. What do we think this API should do? My initial idea was:
WebSocketServer inherits from AsyncResource
WebSocketServer.aclose():
Cancels the listener
Calls aclose() on each open connection
Returns when the listener and all associated tasks have exited.
This approach was a bit tricky to pull off, and after talking about it on Gitter, I realized that I hadn't considered what to do with each connection handler. Should handlers be cancelled? Should we wait for handlers to exit on their own?
If we close a handler's WebSocket, it should raise ConnectionClosed, which would allow each handler to clean up and exit. (But to make this robust, #11 needs to be fixed.) This is roughly what I have already implemented, and I think I favor this approach. What do you think?
Activity
mehaase commentedon Sep 14, 2018
I started to work on this and got stuck. The expected behavior isn't 100% obvious. What do we think this API should do? My initial idea was:
WebSocketServerinherits fromAsyncResourceWebSocketServer.aclose():aclose()on each open connectionThis approach was a bit tricky to pull off, and after talking about it on Gitter, I realized that I hadn't considered what to do with each connection handler. Should handlers be cancelled? Should we wait for handlers to exit on their own?
If we close a handler's WebSocket, it should raise ConnectionClosed, which would allow each handler to clean up and exit. (But to make this robust, #11 needs to be fixed.) This is roughly what I have already implemented, and I think I favor this approach. What do you think?
njsmith commentedon Sep 15, 2018
@belm0 What are you trying to do that's different then just cancelling the server?
belm0 commentedon Sep 15, 2018
Cancel is fine I think. I'd like to see how this works in practice with the new API.