- Home /
RPC , string parameter is sent, but length is 0
Hey, this is called by the server
player.Add(new PlayerStruct{ name = playername, ID = currPlayerJoinedID, isHost = false});
BinaryFormatter bf = new BinaryFormatter();
MemoryStream o = new MemoryStream();
bf.Serialize(o, player);
string data = Utils.StreamConverter.ConvertMemoryStreamToString(o);
print (data.Length);
networkView.RPC("renewPlayerData",RPCMode.Others,data);
And this is the RPC, called by clients
[RPC]
void renewPlayerData(string listData)
{
player.Clear();
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ins = new MemoryStream(Encoding.Default.GetBytes(listData));
player = (List<PlayerStruct>)bf.Deserialize(ins);
}
The parameter in the clientsection is length 0. But on Server its not 0. It seems that the paramter gets corrupted. Any solutions to that?
youve encountered a problem that i am facing right now, i think its a bug in unity but very few people on here know about it except for you, myself, and a handful of others. i am going to try your approach and i will see if that solves anything.
Answer by eddyvanleuten · Jun 01, 2013 at 07:18 AM
Ok, I did it by myself. I just did not send a string, but a byte array.
Your answer
Follow this Question
Related Questions
Not able to pass an instance of a class over a network through OnSerializeNetworkView or an RPC 1 Answer
Making a GUI Label carrying a variable update when changed to all clients on network 0 Answers
How to send timestamp via RPC so it was relative to the receiver? 1 Answer
Network RPC - exclude specific client 1 Answer
Photon RPC problem... 3 Answers