Polling server events

This is the last step of the server integration! 😆

Events must be polled as often as possible, preferably every “server frame”.

The server-side events are:

  • equ8_event_id_send_request. EQU8 has data to send.

  • equ8_event_id_status. Status for the given user has changed (banned for instance).

If we received a equ8_event_id_send_request event, EQU8 has data that should be sent to the client.

If we received a equ8_event_id_status event, the status for the given client has changed; we simply re-run the user_is_allowed_to_play-function.

EQU8 will NEVER send more than 256 (0x100) bytes in a single packet.

C/C++

switch(equ8_sm_poll_event(c.unique_id(), &equ8_data))
{
    case equ8_event_id_send_request:
    {
        std::cout << "EQU8 Data Send Request: user: '"
            << c.unique_id() << "' size: "
            << equ8_data.send_request.size << std::endl;
        packet_equ8_data session{
            equ8_data.send_request.payload,
            equ8_data.send_request.size };
        //
        // Send the EQU8 data to the client
        //
        send_packet(c, &session);
        break;
    }
    case equ8_event_id_status:
    {
        if(!user_is_allowed_to_play(c.remote_in(), c.unique_id(),
            equ8_data.status.action))
        {
            std::cout << "Client '" << c.unique_id()
                << "' kicked (action: "
                << equ8_data.status.action << ")" << std::endl;
            return false;
        }
        break;
    }
}

Last updated