Reputation: 21
Note: I have had a read of a few suggested threads by the prompt before writing this, but I didn't ascertain the answer I'm looking for.
I have a quick question about websockets and establishing the type of the data when sending communications in binary and understanding what type it is when received?
For example, if I have an object which has the following schema {string, string, int, int, DateTime}, how could I send this object in binary using websockets? How could I also ensure they know the schema of the message they receive so they can properly parse it?
It seems libraries like SignalR abstract this away but I'd love to know how it works under the hood. Thank you
Upvotes: 1
Views: 2151
Reputation: 38764
I have a quick question about websockets and establishing the type of the data when sending communications in binary and understanding what type it is when received?
The WebSocket protocol allows sending different message formats per message. It can be UTF8 text or binary. The application using these APIs get to decide what to send, and the consumer can read the message and tell if it's binary or UTF8 encoded text. Now that's just the high level protocol but the application also needs to wrap messages in a serialization format (could be raw text, JSON anything that can be encoded in a sequence of bytes). This is where libraries like SignalR do their magic.
It seems libraries like SignalR abstract this away but I'd love to know how it works under the hood.
There are 2 versions of SignalR:
Upvotes: 2