- Home /
Using an RPC call within an RPC function?
is it possible to send an RPC call to a client from an RPC function on a server? for example, can I send a message to the client with:
[RPC]
void ServerAddInfo(string name, string password, int score, NetworkPlayer player) {
for(int i=0; i < profane.Count; i++) {
if(!name.Contains(profane[i]) && !password.Contains(profane[i])) {
PlayerNode newEntry = new PlayerNode();
newEntry.name = name;
newEntry.password = password;
newEntry.score = score;
newEntry.netPlayer = player;
playerList.Add(newEntry);
Debug.Log(name+" password="+password+" joined the game with a score of "+score);
Refresh(show, newEntry.name, newEntry.score);
}
if(name.Contains(profane[i]) || password.Contains(profane[i])) {
networkView.RPC("RecieveAcceptOrDeny", player, "This is a clean game! Please don't use profanity!");
}
}
}
or can a server not do that? will it do that if i add a networkView on it?
Answer by Waz · Jul 28, 2011 at 12:44 PM
Yes, you can do that just fine.
I have numerous times - it's almost unavoidable.
RPC just queues a message, so no risk of deadlock or anything like that.
Answer by umauj · Mar 30, 2012 at 12:02 PM
Sorry to dig that out again, but I really wanted to share my experience with you! Yes, it works to call RPCs inside RPCs, but it can lead to a misordering!
If the Server makes a RPCMode.All call and INSIDE that invokes a new RPCMode.All, then the RPCs are send in the wrong order to the clients (on the server it's fine). So keep that in mind. I'll file a bug-report, and hopefully this is fixed.
I am having this exact problem. Was there ever a solution to this?
Your answer
Follow this Question
Related Questions
Network.Instantiate doesn't update in Hierarchy? 0 Answers
SyncVar issue 0 Answers
Networking RPC sends to wrong target 0 Answers
Multiple Cars not working 1 Answer
ClientRPC not getting sent. 0 Answers