Accepting player and data
Accepting the player
Next up is calling user_is_allowed_to_play
. It is ideal to verify user status as early as possible after the player has been authenticated and the unique identifier is known.
In the example code we send a small response to the client if it is not allowed to play, but for timeouts and bans, simply dropping the connection will work just as well.
if(packet_type::connect == p->id)
{
const std::string &unique_id =
static_cast<const packet_connect *>(p)->name;
uint32_t status = equ8_sm_user_status(unique_id.c_str());
if(!user_is_allowed_to_play(from, unique_id, status))
{
std::cout << "Client '" << unique_id
<< "' not allowed to play (action: "
<< status << ")" << std::endl;
return;
}
Receiving data from the client
While the vast majority of Anti-Cheat data is sent directly from the client to the Anti-Cheat servers, a few packets need to be sent over the game’s existing data channel.
For instance, after the game server registers a client, an access token must be delivered to the game client so that it can connect to the Anti-Cheat servers directly.
Add a new packet to your game protocol for EQU8 data delivery, and feed the data to EQU8 as you receive the packet.
EQU8 will NEVER send more than 256
(0x100
) bytes in a single packet.
switch(p->id)
{
case packet_type::equ8_data:
std::cout << "EQU8 Received Data from user: '"
<< it->unique_id() << "' size: "
<< static_cast<const packet_equ8_data *>(p)->size
<< std::endl;
equ8_sm_on_data_received(it->unique_id(),
static_cast<const packet_equ8_data *>(p)->data,
static_cast<const packet_equ8_data *>(p)->size);
return;
Last updated
Was this helpful?