Consider the following situation: (Pseudo-ish code)
//All our luscious data
char theChar = 123;
int theInt = 4324;
char[] theCharArray = "sometext";
//Make an array to hold all of that data.
byte[] allTheVars = new *byte[sizeOfArray];
//Copy all vars into "allTheVars"
copyToEndOfArray(theChar, allTheVars);
copyToEndOfArray(theInt, allTheVars);
copyToEndOfArray(theCharArray, allTheVars);
So the idea is that you end up with a bunch of variables strung together into the same byte array. This array is then passed over the internet. Now say all these variables were sent over to call a remote function, like below.
//This is the function that will take in the data we sent over the network.
void remotelyCalledInternetFunction(char aChar, int anInt, char[] aCharArray)
{
}
Instead of manually splitting up each variable into it's specified type by means of tediously copying from the byte array, can you have the method "auto-split" the varaibles by doing something like this?
//Pass the byte array. The method knows what types it needs, maybe it will auto-split the data correctly?
remotelyCalledInternetFunction(allTheVars);
If not, is there anything similar I could do?
EDIT: Any way to do something like this?
remotelyCalledInternetFunction(allTheVars);
//Takes first 2 bytes of the array, the next 4 bytes, and the rest for the char[]?
void remotelyCalledInternetFunction(char aChar, int anInt, char[] aCharArray)
{
}