2. Perform Connectivity Check with Test Client
Introduction
The Diarkis Server Template includes a test client designed 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 (it is disabled by default and not needed this time)
ms (MARS Stats) Tool
This is a tool for retrieving current information from 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
Start two instances of the test client and try creating and joining a room.
Create a room using the room create
command on one client, and then join that room using the room join
command on the other client.
Create 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
Join 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]
Verify CCU and Room Numbers with ms
Launching two instances of the test client and joining a room confirms that the CCU and Room numbers have increased.
$ 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 ...
Sending Messages to All Room Members
Use the room broadcast
command to send any message.
You can also use the shorthand room +
for the same purpose.
Broadcasting from 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 the Message with uid: test2
[UID: test2][SID(UDP): zzzz][RoomID: yyyy]
> Room broadcast - Hello, Diarkis!!
Sending Messages to Specific Room Members
Use 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 the Message with uid: test2
[UID: test2][SID(UDP): zzzz][RoomID: yyyy]
> Room message - nice!
Leaving a Room
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
Use the help
command to see a list of available commands.
By adding a module name as an argument, such as help room
, you can narrow down the commands 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
=============================================
Last updated
Was this helpful?