Can you send messages directly?

I am porting my game from the PC to unity. I already use RakNet and heard that if I downgrade from 4 to 3.7 it should work.

However, I have many, MANY, lines of code on the client/server that looks like this:

theBitStream.Reset();
theBitStream.Write(typeId);
theBitStream.Write(int);
theBitStream.Write(int);
theBitStream.Write(string);
theBitStream.Write(object);
peer->Send(&theBitStream, HIGH_PRIORITY, RELIABLE, 0, RakNet::UNASSIGNED_SYSTEM_ADDRESS, true);

I don’t fully understand how the serialize function in unity works but it doesn’t seem like what I want.

Is the best option here to replace all writing to a stream with a remote procedure call that just appends the variables to the function call as paramaters, and then have a single function on the client that reads all the data and then parses? Will this work if I send 100+ variables at a time?

At first I was just going to use the C# version of RakNet and everything would work but I found out the web player wouldn’t be able to run the external library. So now I am stuck with the built in Unity stuff so any advice would be appreciated. Many of the tutorials online give 404 errors so its hard to find actual code examples.

I want to minimize the amount of work in the conversion so any help would be greatly appreciated.

Unity’s networking has been customized heavily,
take a look at the RPC method which is used to send data.

Thank you for the advice. FYI RPC = Remote Procedure Call, I was just asking if that was the right thing to use. Apparently it is… thank you.