I set up a buffered RPC which i can confirm is being called on the server side, which is set to RPCMode.OthersBuffered. However this RPC never seems to be called on the client side when they connect to the server.
The component in which the RPC should be called is not instantiated at first when the client connects to the server. The client actually loads the level after a successful connection is made, but when the Component is instantiated and added to the game, the client never gets this buffered RPC. Is the buffered RPC not getting called because when the client first connects the network view with that specific ID is not available, or should buffered RPC’s get called as soon as the NetworkView with the correct ID is available?
I was able to solve this problem temporarily by having the client request the information it needs from the server through an RPC then the server responds with the information, but it would be easier if my buffered RPCs would just work. Could someone explain how networkviews need to be set up for buffered RPC’s to work?
Did you setup the buffered call on the server? (so you used an RPC to call client → server to request something and then a buffered of server to all other which sents out the actual RPC to all buffered)
Buffered from client will not be replicated later on as clients don’t have the authority to buffer RPCs
No, when I was attempting to use the buffered RPC, on initialization of the server I called the buffered RPC with RPCMode.OthersBuffered and I also tried RPCMode.AllBuffered on the server. I could confirm on the server with Allbuffered that the RPC would be called on the server, but no other clients connecting to the server would receive the RPC later on. However the clients on first connect to the server do not have the networkview that the RPC is called on, it is instantiated when the level is loaded. Is this why its not called?
Run a client in the editor, and run the server in a compiled thing.
What you need to check for is an error in the output log saying something about receiving an rpc, but the object doesn’t exist.
Because yes, it’s highly probable you are connecting to the server, receiving rpcs for non-existant objects, then loading a new level. I had a similar problem.
The ‘catch-all’ way to fix this is this:
function OnConnectedToServer() {
Debug.Log("Connected to server");
Network.isMessageQueueRunning = false;
}
Basically, what happens is the onconnectedtoserver will be run BEFORE any rpcs are called. By disabling the message queue, all the rpcs get received still (if I remember correctly), but aren’t actually run. This of course needs to be in the scene where you’re connecting to the server and stuff, not in the scene you’re going to load.
Once you’ve loaded the level and stuff, merely re-enable the message queue. The received rpcs should then all call upon the next tick.
Thanks cerebrate, i got my thing going on properly thanks to this information.
My game enters the server before loading the scene so the object was definitely not there yet.
To solve this, i reactivated that network property using this:
function OnLevelWasLoaded (level : int) {
if (level == 1) {
Network.isMessageQueueRunning = true;
}
}
Of course one can drop the if statement, but it’s safer to check where you are
Thanks for the simple but critical info!
Thank you! I think your explanation should be somewhere in the official docs. I was having such a hard time with this problem. Your solution made my issue go away.