SuperTuxKart
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. More...
 
std::shared_ptr< STKPeergetPeerSP () const
 Returns the peer of this event (shared pointer). More...
 
STKPeergetPeer () const
 Returns the peer of this event. More...
 
const NetworkStringdata () const
 Get a const reference to the received data. More...
 
NetworkStringdata ()
 Get a non-const reference to the received data. More...
 
bool isSynchronous () const
 Determines if this event should be delivered synchronous or not. More...
 
uint64_t getArrivalTime () const
 Returns the arrival time of this event. More...
 
PeerDisconnectInfo getPeerDisconnectInfo () const
 

Private Attributes

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

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]

const NetworkString& Event::data ( ) const
inline

Get a const reference to the received data.

This is empty for events like connection or disconnections.

◆ data() [2/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.

◆ getArrivalTime()

uint64_t Event::getArrivalTime ( ) const
inline

Returns the arrival time of this event.

◆ getPeer()

STKPeer* Event::getPeer ( ) const
inline

Returns the peer of this event.

◆ getPeerSP()

std::shared_ptr<STKPeer> Event::getPeerSP ( ) const
inline

Returns the peer of this event (shared pointer).

◆ getType()

EVENT_TYPE Event::getType ( ) const
inline

Returns the type of this event.

◆ isSynchronous()

bool Event::isSynchronous ( ) const
inline

Determines if this event should be delivered synchronous or not.

Only messages can be delivered synchronous.

Member Data Documentation

◆ m_arrival_time

uint64_t Event::m_arrival_time
private

Arrivial time of the event, for timeouts.

◆ m_data

NetworkString* Event::m_data
private

Copy of the data passed by the event.

◆ m_pdi

PeerDisconnectInfo Event::m_pdi
private

For disconnection event, a bit more info is provided.

◆ m_peer

std::shared_ptr<STKPeer> Event::m_peer
private

Pointer to the peer that triggered that event.

◆ m_type

EVENT_TYPE Event::m_type
private

Type of the event.


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