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++

C/C++
C#
1
switch(equ8_sm_poll_event(c.unique_id(), &equ8_data))
2
{
3
case equ8_event_id_send_request:
4
{
5
std::cout << "EQU8 Data Send Request: user: '"
6
<< c.unique_id() << "' size: "
7
<< equ8_data.send_request.size << std::endl;
8
packet_equ8_data session{
9
equ8_data.send_request.payload,
10
equ8_data.send_request.size };
11
//
12
// Send the EQU8 data to the client
13
//
14
send_packet(c, &session);
15
break;
16
}
17
case equ8_event_id_status:
18
{
19
if(!user_is_allowed_to_play(c.remote_in(), c.unique_id(),
20
equ8_data.status.action))
21
{
22
std::cout << "Client '" << c.unique_id()
23
<< "' kicked (action: "
24
<< equ8_data.status.action << ")" << std::endl;
25
return false;
26
}
27
break;
28
}
29
}
Copied!
1
switch (equ8.session_manager.poll_event(c.name, ev))
2
{
3
case equ8.equ8_event_id.send_request:
4
{
5
Console.WriteLine(
6
"EQU8 Data Send Request: user: '{0}' size: {1}",
7
c.name, ev.get_send_event_size());
8
send_packet(c, new packet_equ8_data(
9
ev.duplicate_send_event()));
10
}
11
break;
12
case equ8.equ8_event_id.status:
13
{
14
var action = ev.get_status_action();
15
if (!user_is_allowed_to_play(c.addr, c.name, action))
16
{
17
Console.WriteLine("Client '{0}' kicked (action: {1})",
18
c.name, action);
19
remove_client(i);
20
}
21
}
22
break;
23
}
Copied!
Last modified 1yr ago
Copy link