how rpc work

I want to know when i use rpc in RPCMode.All mode. How it work.

For example. Here ABC, A and C is client. B is server.

now A call a rpc function use RPCMode.All. How the msg to send?

Is A to C and B ? or A to B, then B to C(other)?

if the first. how it know the C’s address?
if the second. can i make some check on B’s rpc function to control whether this time will send this msg to other client?

Every client knows the server only, and the server knows every client.

So I assume when you use RPCMode.All from a client, unity is smart and sends it to the server which sends it to other players.

You can also directly call a RPC method from a client to another (and here again, unity hides to you the redirection threw the server, but it exists).

All the RPCModes are listed in Unity - Scripting API: RPCMode . RPCMode.All sends the RPC call to everyone; server & all clients, incl. the sender.

Ok, imagine a situation like, a client asks the server to check a password or stats or something, in this case you can let the client send a message to the server, the server can use info.sender to reply to the specific client.

there is tow question.

first, is there any function like “Network.Instantiate” with “OnNetworkInstantiate”, or like “Destroy” with “OnDestroy”. When client call a rpc function before it invoke can go a special function. so that i can do something before invoke.

second, if client use all mode. how to stop this rpc invoke to other? i mean may be some client want to send to all. but server say no. so this rpc invoke stop by server.