easywsclient icon indicating copy to clipboard operation
easywsclient copied to clipboard

Distinguishing text/binary messages

Open jpek42 opened this issue 8 years ago • 3 comments

Hi -

Thanks for the work on this library. It's certainly the easiest-to-consume C++ WS library I've come across.

One thing that I don't see is a way to determine whether an incoming message is binary or text. The _dispatchBinary method gets the opcode, but then just eats it without telling the callable. It seems like it would make sense to pass the type on as well.

Or maybe I'm missing something in the way things are supposed to work.

jpek42 avatar May 04 '16 10:05 jpek42

Hi @jpek42, sorry for taking awhile to get back to this issue. This is a limitation of the API: The information about text or binary can be inspected based on which callback was called. I.e., two callbacks need to be registered, one for text and one for binary.

dhbaird avatar Jun 11 '16 15:06 dhbaird

Thanks for the response. I guess it wasn't clear what those 2 methods were (dispatch, dispatchBinary). Are they just establishing callbacks? So there's no need to call them within the loop?

jpek42 avatar Jun 11 '16 19:06 jpek42

Hi @jpek42, the original issue you raise is accurate: this is a limitation of the API, and also unexpected/confusing.

The easiest solution would be: make sure that your service ever only sends one or the other (text or binary), and never mixes them.

The more better solution would be to fix the API. I will see if I can do that this weekend, or pull requests are also welcome. Thanks for reporting this issue.

dhbaird avatar Jun 23 '16 05:06 dhbaird