SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Event Class Reference

Class representing an event that need to pass trough the system. This is used to remove ENet dependency in the network. It interfaces the ENetEvent structure. The user has to be extremely careful about the peer. Indeed, when packets are logged, the state of the peer cannot be stored at all times, and then the user of this class can rely only on the address/port of the peer, and not on values that might change over time. More...

#include <event.hpp>

Public Member Functions

 Event (ENetEvent *event, std::shared_ptr< STKPeer > peer)
 
 ~Event ()
 Destructor that frees the memory of the package.
 
EVENT_TYPE getType () const
 Returns the type of this event.
 
std::shared_ptr< STKPeergetPeerSP () const
 Returns the peer of this event (shared pointer).
 
STKPeergetPeer () const
 Returns the peer of this event.
 
const NetworkStringdata () const
 Get a const reference to the received data.
 
NetworkStringdata ()
 Get a non-const reference to the received data.
 
bool isSynchronous () const
 Determines if this event should be delivered synchronous or not.
 
uint64_t getArrivalTime () const
 Returns the arrival time of this event.
 
PeerDisconnectInfo getPeerDisconnectInfo () const
 

Private Attributes

NetworkStringm_data
 Copy of the data passed by the event.
 
EVENT_TYPE m_type
 Type of the event.
 
std::shared_ptr< STKPeerm_peer
 Pointer to the peer that triggered that event.
 
uint64_t m_arrival_time
 Arrivial time of the event, for timeouts.
 
PeerDisconnectInfo m_pdi
 For disconnection event, a bit more info is provided.
 

Detailed Description

Class representing an event that need to pass trough the system. This is used to remove ENet dependency in the network. It interfaces the ENetEvent structure. The user has to be extremely careful about the peer. Indeed, when packets are logged, the state of the peer cannot be stored at all times, and then the user of this class can rely only on the address/port of the peer, and not on values that might change over time.

Member Function Documentation

◆ data() [1/2]

NetworkString & Event::data ( )
inline

Get a non-const reference to the received data.

A copy of the message data. This is empty for events like connection or disconnections.

◆ data() [2/2]

const NetworkString & Event::data ( ) const
inline

Get a const reference to the received data.

This is empty for events like connection or disconnections.

◆ isSynchronous()

bool Event::isSynchronous ( ) const
inline

Determines if this event should be delivered synchronous or not.

Only messages can be delivered synchronous.


The documentation for this class was generated from the following files: