So lets say I have a byte array byte[] bytes
which is initialised with some data(Client side).
The contents of the byte array can be of type A
or B
.
Then I want to sent the array over to my server. And I want the server to be able to identify which of the two types of data the array contains (A
or B
)
I thought about adding one more byte (as it is going to be only a couple of types. maybe 3) as a prefix to the beginning of the array so that the server can identify the type, then remove the first byte and read the contents.
Is there a reason why I shouldn't do that? Is there another approach better than that?
P.S. I don't want to send another message prior to my array to inform about the type of the next message