# Diarkis クライアントからサーバに接続する

## はじめに

本ページでは C++ の `room_broadcast` サンプルを使用して「Diarkis サーバーをローカル環境で起動する」で起動した Diarkis サーバーに接続して通信を行う方法を説明します。\
`room_broadcast` サンプルでは Room モジュールを使用して Diarkis サーバー上に仮想の部屋を作成し、2人のユーザーが接続してお互いにデータの送受信を行います。 サンプルの詳しい説明は [room\_broadcast](broken://pages/UQBFCMlPKjhZLYEDxmC3) を参照してください。

## Windows 環境

1. `samples/room_broadcast/win-x64/room_broadcast.sln` を Visual Studio で開きます。
2. プロジェクト > プロパティ > デバック > コマンド引数 を指定します。

   ```
    $(endPoint) $(uid) $(clientKey) 例 127.0.0.1:7000 1111 AAAA
   ```
3. F5 でビルドしプログラムを起動します。サンプル・プログラムの起動後、Diarkis サーバーに接続すると以下のようなログが表示されます。

   ```
   Start
   FileLoggerBackend created files ./logs/1111/diarkis-log.log
   ============================
   Loop=1
   Endpoint: 127.0.0.1:7100
   UID     : 1111

   Connecting to the UDP server...
   Connected
   Joining a room...
   Joined
   Room members: 1111
   ```

   `room_broadcast` サンプルでは複数人が Room に接続するのを待ってサンプルの処理を進める流れとなっているため１人が接続しただけだと他のユーザーの接続を待つ状態となります。
4. Windows ターミナル(コマンド・プロンプト)などから、別プロセスで複数クライアントを実行します。\
   `samples/room_broadcast/win-x64/x64/Debug/bin/room_broadcast.exe` に実行ファイルが出力されています。

   ```
   > ./x64/Debug/bin/room_broadcast.exe $(endPoint) $(uid) $(clientKey)
   例 : room_broadcast.exe 127.0.0.1:7000 2222 BBBB
   ```

   2人のユーザーが Diarkis サーバに接続すると以下のログが出力され、Diarkis サーバーの Room モジュールを介したデータの送受信が行われていることが確認できます。

   ```
   Connecting to the UDP server...
   Connected
   Joining a room...
   Joined
   Room members: 1111, 2222
   Room Broadcast
   Stats Room Broadcast num 100
   Stats Room Broadcast num 200
   Stats Room Broadcast num 300
   ```

## macOS 環境

Coming Soon

## Linux 環境

Coming Soon


---

# 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/getting-started/tutorial/setup-client.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.
