Unique identifier & reading user

Choosing a unique identifier.

EQU8 needs an identifier that is unique across all players. This identifier is used to correlate events in our database with your database. The identifier can be anything from a user name to a database integer; so long as it is unique it will work. So, before we continue, decide on what identifier to use.

Reading the EQU8 user status

Before allowing a client to play, we want to verify that she is well behaved (not banned etc).

In the example server we write a function named user_is_allowed_to_play that talks to the EQU8 user validation API.

Initially, let us just use the predefined actions (ban and timeout 15 minutes). However, using EQU8 you can implement whatever actions you see fit! Be it an all-cheaters server or a virtual jail :)

C/C++

bool user_is_allowed_to_play(const sockaddr_in &from,
    const std::string &unique_id, uint32_t action)
{
    auto from_sa = reinterpret_cast<const sockaddr *>(&from);

    if(equ8_action_ban == action)
    {
        packet_violation pv{ "You are banned." };
        send_packet(from_sa, sizeof(from), &pv);
        return false;
    }
    else if(equ8_action_timeout_15m == action)
    {
        packet_violation pv{ "You are timed-out." };
        send_packet(from_sa, sizeof(from), &pv);
        return false;
    }
    return true;
}

Last updated