Ability to determine if a message is binary or text
Currently, the API only has OnMessage(byte[] bytes), but this doesn't allow us to determine if the message was encoded as binary or text. This data is known to the library via WebSocketMessageType, so I suggest this be exposed to clients as well.
Some options:
- Add a second parameter, like:
OnMessage(byte[] bytes, WebSocketMessageType messageType) - Create separate events, like:
OnMessageText(string data)andOnMessageBinary(byte[] bytes).
I'd be happy to submit a PR implementing either approach, let me know what you think!
Thanks again for this great library.
how about this library? @aroman https://github.com/psygame/UnityWebSocket
Thanks for sharing your library! Actually I ended up only needing binary messages, but if I end up needing this feature I will look more closely into it.
Yes, this would be important to seperate data from commands.