Network.RemoveRPCs

Greetings,

It means RPCs functions can’t be called anymore ? I guess this action can’t be undone ?
But the state synchronization stay, so data can still flow ?

No, it means any Buffered RPC calls that have been made using the specified NetworkViewID will be removed from the buffer.

Example

If I call an RPC like so

networkView.RPC("doSomething", RPCMode.AllBuffered, aParameter);

That RPC call is buffered and any further clients that connect latter will recieve this (and all other buffered RPC calls) when they connect.

If you then

Network.RemoveRPCs(networkView.viewID);

the RPC call will be removed from the buffer, along with any other RPCs associated with the given viewID.

Now when a new client connects they won’t recieve those RPC calls on connection anymore as they are no longer in the buffer.

Simple and clean, thanx you !

Additional question :

I guess if I were removing all RPC functions calls associated with all NetworkView of a precise player (by calling several times RemoveRPCs (viewID : NetworkViewID), it would be the same effect as calling RemoveRPCs (playerID : NetworkPlayer) with playerID = the targetted player ?

Not necessarily, you don’t have to be the owner of a NetworkView to make an RPC call on that view. Consider the following.

There are 3 players: ClientA, ClientB and ClientC.

There is a script with an RPC method which is attached to a aGameObject along with a NetworkView. The NetworkView is owned by ClientA.

[RPC]
public void rpcCall(int index)
{
  // do stuff
}

The following calls occur:

Call X = ClientA makes an rpcCall using aGameObject.networkView to RPCMode.AllBuffered
Call Y = ClientB makes an rpcCall using aGameObject.networkView to RPCMode.AllBuffered
Call Z = ClientC makes an rpcCall using aGameObject.networkView to RPCMode.AllBuffered

So in the buffer you now have:
Call X
Call Y
Call Z

At this point if you call

Network.RemoveRPCs(ClientA_NetworkPlayer);

You would be left with the following calls in the buffer:
Call Y
Call Z

If instead you called

Network.RemoveRPCs(aGameObject.networkView.viewID);

You would be left with nothing in the buffer.

I see the nuance. Thanx you very much !