We explain the sample custom commands for Diarkis MatchMaker.
There are two sample matchmaking implemented for UDP and/or TCP server.
cmds/custom/main.go
Sample Matching IDs
-
RankMatch
- rank is range of 5
-
RateAndPlay
-
rate is range of 1
-
play is range of 1
-
MatchMaker Add Command For UDP/RUDP and TCP
MatchMaker add command creates a new room and adds to MatchMaker to be searched and found.
Client receives a response with ver:2 and cmd:100 to evaluate success or failure of the command.
Client raises On Room Creation event if successful.
Command Version and ID
ver: 2
cmd: 100
Payload
Endianness is Big Endian.
+--------+-----------+-----------------+--------------------+
| TTL | *Size | String List | Property Map |
+--------+-----------+-----------------+--------------------+
| 8 byte | 2 byte | *Size | variable size |
+--------+-----------+-----------------+--------------------+
| 0 7 | 8 9 | 10 10 + *size | 10 + *size + 1 ... |
+--------+-----------+-----------------+--------------------+
String List
+---------+-------------+----------+-----------+
| *size | Matching ID | **size | Unique ID |
+---------+-------------+----------+-----------+
| 4 byte | *size | 4 byte | **size |
+---------+-------------+----------+-----------+
Property Map
Property Value, size, and Property Name may repeat as a set of data.
+----------------+--------+---------------+
| Property Value | *size | Property Name |
+----------------+--------+---------------+
| 4 byte | 2 byte | *size |
+----------------+--------+---------------+
| 0 3 | 4 5 | 6 6 + *size |
+----------------+--------+---------------+
MatchMaker Search Command For UDP/RUDP and TCP
MatchMaker search finds rooms that matches the given properties (conditions) and join the found room.
Client receives a response with ver:2 and cmd:102 to evaluate success or failure of the command.
Remote clients that already matched receives a server push with ver:2 and cmd:103 to notify the matched room is now full.
Remote clients that already matched raise On Member Join event on successful search.
Command Version and ID
ver: 2
cmd: 102
Payload
+--------+-----------------+---------------+
| *size | String List | Property Map |
+--------+-----------------+---------------+
| 2 byte | *size | Variable |
+--------+-----------------+---------------+
| 0 1 | 2 2 + *size | 2 + *size ... |
+--------+-----------------+---------------+
String List
size and Matching ID may repeat as a set of data.
+---------+-------------+
| *size | Matching ID |
+---------+-------------+
| 4 byte | *size |
+---------+-------------+
Property Map
Property Value, size, and Property Name may repeat as a data set.
+----------------+--------+---------------+
| Property Value | *size | Property Name |
+----------------+--------+---------------+
| 4 byte | 2 byte | *size |
+----------------+--------+---------------+
| 0 3 | 4 5 | 6 6 + *size |
+----------------+--------+---------------+
P2P Address Report Command For UDP/RUDP and TCP
The command is used to report the client's public address meant for peer-to-peer communication.
This command assumes the client has joined a room.
Command Version and ID
ver: 2
cmd: 110
Payload
Client Address is a byte array encoded UTF8 string.
+---------------+----------------+
| Custom Header | Client Address |
+---------------+----------------+
| 5 byte | Variable |
+---------------+----------------+
| 0 4 | 5 ... |
+---------------+----------------+
P2P Initialize Command For UDP/RUDP and TCP
Starts peer-to-peer communication with all members of the room the client is in.
Client receives a response with ver:2 and cmd:111 to evaluate success or failure of the command.
All remote clients that are members of the room raise On Member Broadcast with a list of other client's addresses.
The clients may use those addresses to initiate peer-to-peer communication immediately.
Command Version and ID
ver: 2
cmd: 111
Payload
Empty payload.
Payload Of On Member Broadcast
String List
size and Client Address may repeat as a set of data.
+---------+----------------+
| *size | Client Address |
+---------+----------------+
| 4 byte | *size |
+---------+----------------+