1c3t3a / rust-socketio

An implementation of a socket.io client written in the Rust programming language.
MIT License
389 stars 69 forks source link

Binary Data event names incorrectly handled #426

Open kitgxrl opened 2 months ago

kitgxrl commented 2 months ago

Currently if there is some additional data attached to a binary event, it is not possible to retrieve that additional data, e.g xxx["my_binary_event", "extra data"] is not correctly handled. The worst case scenario is that the event name is labelled entirely wrong. In the previous example the library currently just strips the brackets and ", which would cause an event name of: my_binary_eventextra data or something along those lines.

kitgxrl commented 2 months ago

In order to fix this while extracting the additional data I see three solutions:

  1. Introduce Payload::BinaryText(Bytes, Vec<Value>)
  2. Change Payload::Binary(Bytes) to Payload::Binary(Bytes, Vec<Value>) (Potentially Option<Vec<Value>> for easier checking?)
  3. Emit both Payload::Text and Payload::Binary separately

    1 sounds the best as it does not break the existing API and is easier to handle when both the binary data and additional Text data are related.