# 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).
