2. Confirm Connectivity with Test Client

This section assumes the completion of the tutorial in step 1.

Introduction

The Diarkis Server Template includes a test client to test commands. This test client is written in Go.

With this client, you can issue basic built-in commands to verify communication.

Building the Test Client

The binary for the test client can be built using the Diarkis server template.

The test client is built when you previously executed make build-local in the previous tutorial, so you can use that.

Launching the Diarkis Test Client

Execute the following make task:

$ make go-cli host=127.0.0.1:7000 uid=test1
:
[UID: test1][SID(UDP): b674cd4a79594581b90186818c1ef911]
 > Connected UDP
  • host: Endpoint of the Diarkis server

  • uid: ID of the connecting user

  • clientKey: Client key (disabled by default and not needed for this session)

ms (MARS Stats) Tool

This tool is used to obtain the current information of Diarkis.

It provides valuable data for analysis like current CCU, packet numbers, and Room numbers.

# ./remote_bin/ms {MARS address:port} {no-color}
$ watch ./remote_bin/ms 127.0.0.1:6779 no-color
─────────────────────────────────────────────────────────────────────────────────────────── 1.1.0 ───────────────────────────────────────────────────────────────────────────────────────────────────
ADDRESS                    PUBLIC-ADDRESS   STATUS   STARTED                            CCU   MESH-IN   MESH-OUT   UDP-IN   UDP-OUT   TCP-IN   TCP-OUT   MM-SEARCH   ROOMS   P2P-ATTEMPTS   P2P-SUCCESS
HTTP/HTTP/127.0.0.1:8100   127.0.0.1:7000   ONLINE   2024-10-04T17:58:39+09:00[16min]   0     2         2          0        0         0        0         0           0       0              0
UDP/UDP/127.0.0.1:8101     127.0.0.1:7100   ONLINE   2024-10-04T17:58:40+09:00[16min]   1     2         2          0        0         0        0         0           0       0              0

Creating and Joining a Room

Let's start two test clients and create/join a room.

Create a room with one client using the room create command, then join the room with the other client using the room join command.

Creating a Room with uid: test1

> room create
Which client to create a room? [tcp/udp] > udp
[UID: test1][SID(UDP): xxxx][RoomID: yyyy]
> New member joined room - Hello from test2

Joining a Room with uid: test2

> room join
Which client to join a room? [tcp/udp] udp
Type room ID > yyyy
handleOnJoinRoom
UDP Room yyyy joined - success true and it was created at 1728033877
New member joined room - Hello from test2
[UID: test2][SID(UDP): zzzz][RoomID: yyyy]

Checking CCU and Room Count with ms

You can verify that the CCU and room count have increased by having two test clients join the room.

$ watch ./remote_bin/ms 127.0.0.1:6779 no-color
────────────────────────────── 1.1.0 ─────────────────────────────────
ADDRESS                    PUBLIC-ADDRESS   STATUS   CCU ... ROOMS ...
HTTP/HTTP/127.0.0.1:8100   127.0.0.1:7000   ONLINE   0   ...   0   ...
UDP/UDP/127.0.0.1:8101     127.0.0.1:7100   ONLINE   2   ...   1   ...

Broadcasting a Message to All Room Members

You can issue the room broadcast command to send any message.

You can also achieve the same with the shorthand room +.

Broadcasting with uid: test1

> room broadcast
Which client to broadcast to a room? [tcp/udp] udp
Type room ID: yyyy
Type message: Hello, Diarkis!!
Room broadcast - Hello, Diarkis!!
[UID: test1][SID(UDP): xxxx][RoomID: yyyy]

Receiving a Message with uid: test2

[UID: test2][SID(UDP): zzzz][RoomID: yyyy]
 > Room broadcast - Hello, Diarkis!!

Sending a Message to a Specific Room Member

You can issue the room message command to send a message to a specific member.

Sending from uid: test1 to test2

> room message
Which client to message to a room? [tcp/udp] udp
Type user ID: test2
Type message: nice!
[UID: test1][SID(UDP): xxxx][RoomID: yyyy]

Receiving a Message with uid: test2

[UID: test2][SID(UDP): zzzz][RoomID: yyyy]
 > Room message - nice!

Leaving a Room

You can issue the room leave command to exit a room.

[UID: test1][SID(UDP): xxxx][RoomID: yyyy]
> room leave
Which client to leave a room? [tcp/udp]
udp
Type room ID:
yyyy
Room left. success:true
[UID: test1][SID(UDP): xxxx]

Checking Test Client Commands

You can confirm the list of available commands with the help command.

By putting a module name as an argument like help room, you can narrow down the list to specific modules.

> help
================ Command List ================
help                    - Display the list of valid commands
help {module name}      - Display the list of valid commands for the module
reconnect               - Reconnects to another server
disconnect              - Disconnects
ph                      - Sends a TCP Hey
h                       - Sends a UDP Hello
rh                      - Sends an RUDP Hello
die                     - Ungraceful disconnect from the server
:
=============================================
 > help room
================ Command List ================
room create             - Creates a room
room join               - Joins a room
room join random        - Joins a random room or creates a new room
room leave              - Leaves a room
room get owner          - Get a room owner id
room get members        - Get a room member ids
room get num            - Get a number of room members
room migrate            - Migrates a room to another server
room message            - Sends a message to one selected member of the room
room broadcast          - Reliable broadcast to a room
room +                  - Alias for `room broadcast`
room ubroadcast         - Unreliable broadcast to a room
room -                  - Alias for `room ubroadcast`
room p2p                - Starts P2P with room members
room relay              - Sends a relay message to other room members
room relay to           - Sends a relay message to selected room members
room relay profile      - Sends a relay profile
room relay to profile   - Sends a relay profile to selected room members
room props update       - Update room property
room props get          - Get room property
room props incr         - Increment room property
room props sync         - Sync room property
room reserve            - Reserves a room
room cancel reservation - Cancel a room reservation
room register           - Registers a room with a type
room find               - Finds rooms by type
room obj incr           - Increment room objects
room obj delete         - Delete room objects
room obj update         - Update room objects
room chat               - Chat in a room
room chat log           - Get chat log in a room
=============================================

最終更新