R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
ENetPeerWrapper Class Referencefinal

#include <ENetPeer.hpp>

Inheritance diagram for ENetPeerWrapper:
Inheritance graph
Collaboration diagram for ENetPeerWrapper:
Collaboration graph

Public Member Functions

 ENetPeerWrapper (ENetPeer *peer)
 
bool send (std::unique_ptr< IPacket > packet, uint8_t channelID) override
 Send a packet to this peer.
 
void disconnect (uint32_t data) override
 Disconnect from this peer.
 
void disconnectNow (uint32_t data) override
 Force an immediate disconnect from this peer.
 
void disconnectLater (uint32_t data) override
 Disconnect from this peer after all queued packets are sent.
 
PeerState getState () const override
 Get the current state of this peer.
 
const IAddressgetAddress () const override
 Get the address of this peer.
 
uint32_t getID () const override
 Get a unique identifier for this peer.
 
uint32_t getRoundTripTime () const override
 Get the round-trip time (ping) to this peer.
 
void setData (void *data) override
 Set application-specific data associated with this peer.
 
void * getData () const override
 Get application-specific data associated with this peer.
 
ENetPeer * getNativePeer () const
 
- Public Member Functions inherited from IPeer
virtual ~IPeer ()=default
 

Private Attributes

ENetPeer * _peer
 
std::unique_ptr< ENetAddressWrapper_cachedAddress
 

Detailed Description

Definition at line 15 of file ENetPeer.hpp.

Constructor & Destructor Documentation

◆ ENetPeerWrapper()

ENetPeerWrapper::ENetPeerWrapper ( ENetPeer *  peer)
explicit

Definition at line 13 of file ENetPeer.cpp.

References _peer.

Member Function Documentation

◆ disconnect()

void ENetPeerWrapper::disconnect ( uint32_t  data)
overridevirtual

Disconnect from this peer.

Parameters
dataOptional user data to send with the disconnect notification.

Implements IPeer.

Definition at line 40 of file ENetPeer.cpp.

References _peer.

◆ disconnectLater()

void ENetPeerWrapper::disconnectLater ( uint32_t  data)
overridevirtual

Disconnect from this peer after all queued packets are sent.

Parameters
dataOptional user data to send with the disconnect notification.

Implements IPeer.

Definition at line 52 of file ENetPeer.cpp.

References _peer.

◆ disconnectNow()

void ENetPeerWrapper::disconnectNow ( uint32_t  data)
overridevirtual

Force an immediate disconnect from this peer.

Parameters
dataOptional user data to send with the disconnect notification.

Implements IPeer.

Definition at line 46 of file ENetPeer.cpp.

References _peer.

◆ getAddress()

const IAddress & ENetPeerWrapper::getAddress ( ) const
overridevirtual

Get the address of this peer.

Returns
Reference to the peer's address.

Implements IPeer.

Definition at line 94 of file ENetPeer.cpp.

References _cachedAddress, and _peer.

◆ getData()

void * ENetPeerWrapper::getData ( ) const
overridevirtual

Get application-specific data associated with this peer.

Returns
Pointer to user data.

Implements IPeer.

Definition at line 127 of file ENetPeer.cpp.

References _peer.

◆ getID()

uint32_t ENetPeerWrapper::getID ( ) const
overridevirtual

Get a unique identifier for this peer.

Returns
Peer ID or connection index.

Implements IPeer.

Definition at line 107 of file ENetPeer.cpp.

References _peer.

◆ getNativePeer()

ENetPeer * ENetPeerWrapper::getNativePeer ( ) const

Definition at line 59 of file ENetPeer.cpp.

References _peer.

◆ getRoundTripTime()

uint32_t ENetPeerWrapper::getRoundTripTime ( ) const
overridevirtual

Get the round-trip time (ping) to this peer.

Returns
RTT in milliseconds.

Implements IPeer.

Definition at line 114 of file ENetPeer.cpp.

References _peer.

◆ getState()

PeerState ENetPeerWrapper::getState ( ) const
overridevirtual

Get the current state of this peer.

Returns
The peer's state.

Implements IPeer.

Definition at line 63 of file ENetPeer.cpp.

References _peer, ACKNOWLEDGING_CONNECT, ACKNOWLEDGING_DISCONNECT, CONNECTED, CONNECTING, CONNECTION_PENDING, CONNECTION_SUCCEEDED, DISCONNECT_LATER, DISCONNECTED, DISCONNECTING, and ZOMBIE.

◆ send()

bool ENetPeerWrapper::send ( std::unique_ptr< IPacket packet,
uint8_t  channelID 
)
overridevirtual

Send a packet to this peer.

Parameters
packetThe packet to send.
channelIDThe channel ID to send the packet on.
Returns
True if the packet was queued successfully, false otherwise.

Implements IPeer.

Definition at line 19 of file ENetPeer.cpp.

References _peer.

◆ setData()

void ENetPeerWrapper::setData ( void *  data)
overridevirtual

Set application-specific data associated with this peer.

Parameters
dataPointer to user data.

Implements IPeer.

Definition at line 121 of file ENetPeer.cpp.

References _peer.

Member Data Documentation

◆ _cachedAddress

std::unique_ptr<ENetAddressWrapper> ENetPeerWrapper::_cachedAddress
mutableprivate

Definition at line 35 of file ENetPeer.hpp.

Referenced by getAddress().

◆ _peer

ENetPeer* ENetPeerWrapper::_peer
private

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