# DM (Direct Message) Module

## Overview

**Diarkis DM (Direct Message)** is a lightweight, server-relayed communication module designed for **one-to-one message exchange** between users without requiring session initialization or room membership. It enables **direct packet-based communication** by referencing the recipient’s **unique user ID**, offering a fast and simple mechanism for private messaging.

**Technical Overview:**

* **Direct User Addressing:**\
  Messages are sent by specifying the **recipient’s user ID**, eliminating the need for room discovery, matchmaking, or group registration. This enables **instant, ad-hoc communication** between known users.
* **Server-Relay Architecture:**\
  Unlike Diarkis P2P, which attempts direct peer connections, Diarkis DM uses a **server-mediated relay path**, routing messages through **one or two Diarkis servers** to reach the destination client. This ensures message delivery across **NAT-bound and firewall-restricted networks** without requiring hole punching or NAT traversal.
* **Message Routing and Path Efficiency:**\
  The relay path is dynamically determined based on user distribution within the cluster. Diarkis attempts to **minimize server hops**, but **multi-server relaying (up to two hops)** is supported to ensure reliable delivery across distributed server infrastructure.

**Usage Considerations:**

* **Optimized for One-to-One Communication:**\
  While technically capable of sending messages to multiple recipients, Diarkis DM is **not optimized for multicast or broadcast**. For use cases involving multiple users (e.g., chat rooms, game lobbies, or team coordination), **Diarkis Room** or **Diarkis Field** is recommended.
* **Latency and Frequency Constraints:**\
  Due to its server-relay design, Diarkis DM is not ideal for **high-frequency, low-latency data exchange**. Applications requiring **real-time synchronization or rapid event exchange** should consider **Diarkis P2P** or server-side modules that offer lower-latency characteristics.

For integration guidelines and detailed API specifications, refer to the [**Diarkis Server API Reference**](https://docs.diarkis.io/docs/server/current/diarkis/dm/index.html).


---

# 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://help.diarkis.io/en/diarkis-modules/dm.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.
