---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.4
alternate:
  - https://yandex.com/dev/games/doc/en/sdk/construct-3/multiplayer.md
  - https://yandex.com/dev/games/doc/ru/sdk/construct-3/multiplayer.md
  - https://yandex.com/dev/games/doc/tr/sdk/construct-3/multiplayer.md
  - https://yandex.com/dev/games/doc/zh/sdk/construct-3/multiplayer.md
  - href: en/sdk/construct-3/multiplayer.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/games/doc/en/llms.txt

# Asynchronous multiplayer

<!-- source: en/_includes/script-common.md -->
<!-- source: en/_includes/script/index-js.md -->

<!-- endsource: en/_includes/script/index-js.md -->

<!-- source: en/_includes/script/requirements-js.md -->

<!-- endsource: en/_includes/script/requirements-js.md -->

<!-- source: en/_includes/script/image-modal-js.md -->

<!-- endsource: en/_includes/script/image-modal-js.md -->
<!-- endsource: en/_includes/script-common.md -->

The Construct 3 plugin supports asynchronous multiplayer. For more details, see the [HTML 5](https://yandex.com/dev/games/doc/en/sdk/sdk-multiplayer-sessions.md) section.

## Multiplayer initialization {#init}

To get started, use the **Initialize multiplayer** action. It performs initial initialization and loads game sessions of opponents.

Initialization parameters:

#|
|| **Parameter** | **Type** | **Description** ||
|| **Sessions count** | `number` | Number of sessions to load (maximum 10). ||
|| **Turn time** | `number` | Maximum opponent turn time in milliseconds. ||
|| **Meta** | `JSON` | Object with data for session selection. ||
|#

For more details about parameters, see the [main article](https://yandex.com/dev/games/doc/en/sdk/sdk-multiplayer-sessions.md#init).

After successful multiplayer initialization, the **On multiplayer initialization** trigger will be activated. To process the received opponent sessions, use the **For each opponent** loop inside it. The following expressions are available in the loop:

- **Current session player data** — player data in the current session by the `avatar` or `name` key.
- **Current session ID in sessions list**.

To get session metadata, use the **Get current session metadata** action.

## Recording a game session {#record}

Available actions:

- **Commit transaction** — use to commit transactions. The action accepts a JSON object with data.

- **Push session** — use to save the session. The action accepts a JSON object with session metadata.

For more details, see the [main article](https://yandex.com/dev/games/doc/en/sdk/sdk-multiplayer-sessions.md#record).

## Working with sessions {#use}

In Construct 3, working with sessions is done only through events. For this, the **On multiplayer session transactions** and **On multiplayer session finish** triggers are used.

In the **On multiplayer session transactions** trigger, the following are available:

- The **Session ID in event** expression.
- The **For each transaction** loop — for processing the list of incoming opponent transactions. The following expressions are available in the loop:

    - **Current transaction ID in transactions list**.
    - **Current transaction time in transactions list**.

    To get transaction data, use the **Get current transaction data** action.

In the **On multiplayer session finish** trigger, the **Session ID in finish event** expression is available.

To initiate sending sessions to handlers, call the **Mark gameplay start** action. Pausing is done by calling **Mark gameplay stop**.

For more details about working with sessions, see the [main article](https://yandex.com/dev/games/doc/en/sdk/sdk-multiplayer-sessions.md#use).

## Usage example {#example}

![](../../_images/construct-3/multiplayer/example.webp)

---


<!-- source: en/_includes/button-git.md -->
<a href="https://github.com/yandex-games-plugins/construct3">
  <span class="button">Repository</span>
</a>
<!-- endsource: en/_includes/button-git.md -->
