Search Unity

Question [BossRoom] Why using Messaging instead of RPC ?

Discussion in 'Multiplayer' started by Ziboo, May 11, 2021.

  1. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
  2. General rule of thumb (which sometimes gets ignored then, but in general): if you are initiating a command, then use RPC (you expect some action in return).
    If you send notification and stuff, you're messaging (You don't really expect any action in result)
     
    Ziboo likes this.
  3. fernando-a-cortez

    fernando-a-cortez

    Unity Technologies

    Joined:
    Dec 14, 2020
    Posts:
    11
    Hi Ziboo,

    Custom Messages are not bound to any object. RPCs at the moment are bound to a NetworkObject. This means that you must first establish a successful connection with a client before you wish to send RPCs to and from a client. Read more about MLAPI's messaging system here: https://docs-multiplayer.unity3d.com/docs/advanced-topics/messaging-system.

    You'll notice here: https://github.com/Unity-Technologi...cripts/Server/Net/ServerGameNetPortal.cs#L191, that we want to inform the client of the result of the connection approval. In the case where the connect status is a failure, the only way we are able to communicate with a pending client is through Custom Messages because we don’t have NetworkObjects yet to use RPCs on.

    You can consider our usage of Custom Messages as a workaround to this limitation. In the future, we may refactor the connection approval message callback to allow the sending of more contextual connection information.

    Hope this clears that up for you.
     
    dasouth, Ziboo and CreativeChris like this.