Add `code` on `events.CloseConnection` for `wsproto`
I'm not sure if this is the right code, but events.CloseConnection receives code as a mandatory field, so without it, you'll have an exception on missing parameters.
List of codes: https://www.iana.org/assignments/websocket/websocket.xhtml RFC: https://www.rfc-editor.org/rfc/rfc6455.html
I've noticed this issue while annotating wsproto_impl.
Well spotted.
How about we use 1002 "Protocol Error"? That seems like it'd fit quite well here.
The handle_no_connect() method ignores the code from the event anyway. I guess there needs to be some change there.
I've replaced the logic here. :sweat_smile:
I'm fine with this being merged. Thanks @tomchristie 🙏
As a note, wsproto_impl.py is the only file that is missing to add type annotation on uvicorn folder. I'll work on that this week.