python-hyper / wsproto

Sans-IO WebSocket protocol implementation
https://wsproto.readthedocs.io/
MIT License
261 stars 38 forks source link

document state change timing #181

Open belm0 opened 1 year ago

belm0 commented 1 year ago

I wasn't able to find anything in the documentation about when ConnectionState changes, especially for the case where remote is initiating CloseConnection. It's significant in light of the recent change https://github.com/python-hyper/wsproto/commit/b0efe554cca8ac24dcf82940137d04c90351c9c1, which will raise LocalProtocolError if you attempt send a message during REMOTE_CLOSING, etc.

For CloseConnection initiated by the remote, it appears that the state will change when the event is yielded from events(). I don't think the documentation should assume this is obvious, because one might think that state changes at the time of receive_data().