colyseus / colyseus-unity-sdk

⚔ Colyseus Multiplayer SDK for Unity

Home Page:https://docs.colyseus.io/getting-started/unity-sdk/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: Colyseus client cannot recognize custom WebSocket close codes

tonygiang opened this issue · comments

WebSocket close codes in the range 4000-4999 are available for use by applications, but Colyseus Unity client does not recognize them, instead returning 1004 in all cases of custom close codes being sent back. We use this a lot for diagnosis and for custom client rejection messages. Please accommodate these use cases. The Colyseus server API clearly enables developers to send custom close codes.

Now, I technically don't have the clearance to contribute to this project, but I'm free to fork it. And on my fork, I made a very simple change to enable using custom WebSocket close codes. This is for our project's use only, we didn't check for the sub-4000 code range which is reserved by the WebSocket standard. In order to create a custom-close-code-aware implementation to be ready for general public use, that would have to be done first, but if you can guarantee that your server implementation will always throw custom close codes in the 4000-4999 range, my fork is safe too use.