> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maddergames.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Madder Messager

> Functions to interact with the Madder server or individual player controller apps

## Overview

The Madder Messager is a static class that provides functions to interface between the WebGL build and the Unity game.

## Usage

### VibratePlayerController

The `VibratePlayerController` function vibrates a player's controller briefly.
The `gamername` parameter is the gamername of the player controller you want to vibrate and is REQUIRED.

```csharp theme={null}
MadderMessager.VibratePlayerController(string gamername);
```

### VibrateAllPlayerControllers

The `VibrateAllPlayerControllers` function vibrates all player controllers briefly.

```csharp theme={null}
MadderMessager.VibrateAllPlayerControllers();
```

### UpdateMadderPlayerStats

The `UpdateMadderPlayerStats` function updates a player's stats on the Madder server. You decide when this gets called;
however, if your game crashes or the host exits the game without you making the call, the stats will not be updated.

The `MadderPlayer` parameter is a serialized JSON string of the [MadderPlayer](madder-player) object and is REQUIRED.

The `MadderPlayer` object contains the player's gamername and a dictionary of [MadderStat](madder-stat) objects.

```csharp theme={null}
MadderMessager.UpdateMadderPlayerStats(string madderPlayer);
```

### ShowCode

The `ShowCode` function displays the room code on the game screen. This function may be called on `Start()` but **must
not** be called on `Awake()`, or the room code will not display. This function should only be called when not in the
Unity Editor.

```csharp theme={null}
#if !UNITY_EDITOR
    MadderMessager.ShowCode();
#endif
```

### HideCode

The `HideCode` function hides the room code from the game screen. This function should only be called when not in the
Unity Editor.

```csharp theme={null}
#if !UNITY_EDITOR
    MadderMessager.HideCode();
#endif
```
