Unity-SocketIO-Client
Unity-SocketIO-Client copied to clipboard
First byte missing from binary data blobs
This is a very nice socket.io client library, the best I've found for Unity, and I'm happy it uses the same JSON parser I'm using, JSON.net, so it is easy to integrate with my code. (Nobody wants to mix two different JSON parsers, and JSON.net is the best and most standard and widely used I've found.)
It works fine for text messages, but I'm having a problem with sending binary blobs: it's removing the first character of every binary blob!
I'm talking to a node server using the latest socket.io server, and the binary messages are coming from a web browser running the latest socket.io client.
The packets are arriving from the browser socket.io client to the node socket.io server in good condition, and seem to be going out to Unity in good condition.
But I've narrowed it down to this line, that skips for a reason I can't understand, line 145 of SocketIOConnection.cs:
currentPacket.Attachments.Add(e.RawData.Skip(1).ToArray());
https://github.com/dp0ch/Unity-SocketIO-Client/blob/master/Scripts/SocketIOConnection.cs#L145
Since my problems was that one byte was missing, and that code was skipping a byte, I tried removing the .Skip(1), and now it works for me (albeit with limited testing, but now it works all the time for my particular setup)!
But I'd like to understand if that was the right thing to do, why it was doing that, or if this change might break under different circumstances or with different servers, please.
Thank you for developing and sharing Unity-SocketUI-Client, which is very useful, and I hope I can help improve it.