# Concept

## Explanation

Messages utilize the concept of singularity, as they are primarily designed for manager classes and systems within your game. Unlike RPCs, which are meant to synchronize large amounts of data between the client and server (such as movement, health, or power-ups), the messaging system focuses on important functionalities, like a ready-up system, a vote kick system, or sending out a server's complex configuration class.

The singularity concept ensures that only one instance of a particular type can execute a message at a time, except for static messages, which do not require an instance. This means that if you have a player message for each player controller, only one of those controllers will be able to run the message.&#x20;

<figure><img src="/files/Oje39RzvAWTSEhX27bRZ" alt="" width="563"><figcaption></figcaption></figure>

Conversely, if you have a single PlayerManager class for each player, the message will be executed on that single PlayerManager instance.

<figure><img src="/files/Pc4wELgHX6vVh2OLCL6W" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="info" %} <mark style="color:yellow;">Reminder: Static messages do not need an instance to register!</mark>&#x20;
{% endhint %}

## Example

Here is an example on how to register an instance.

```csharp
private void Awake()
{
    // "this" is the instance,
    // that we want to use when a message within the instance gets executed.

    // You can register instance anytime,
    // aslong as you do it before you call the message!
    Messenger.RegisterInstance(this);
    
    // Instances can also be registered per message method.
    Messenger.RegisterInstance(this, nameof(HelloMessage));
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jrcooler.gitbook.io/easy-multiplayer/messenger/concept.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
