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

Interface representing a remote peer in the network. More...

#include <IPeer.hpp>

Inheritance diagram for IPeer:
Inheritance graph
Collaboration diagram for IPeer:
Collaboration graph

Public Member Functions

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

Detailed Description

Interface representing a remote peer in the network.

IPeer represents a connection to another endpoint (client or server). The concrete implementation (ENetPeer, custom connection, etc.) is hidden behind this interface to maintain backend independence.

Definition at line 40 of file IPeer.hpp.

Constructor & Destructor Documentation

◆ ~IPeer()

virtual IPeer::~IPeer ( )
virtualdefault

Member Function Documentation

◆ disconnect()

virtual void IPeer::disconnect ( uint32_t  data = 0)
pure virtual

Disconnect from this peer.

Parameters
dataOptional user data to send with the disconnect notification.

Implemented in ENetPeerWrapper.

◆ disconnectLater()

virtual void IPeer::disconnectLater ( uint32_t  data = 0)
pure virtual

Disconnect from this peer after all queued packets are sent.

Parameters
dataOptional user data to send with the disconnect notification.

Implemented in ENetPeerWrapper.

◆ disconnectNow()

virtual void IPeer::disconnectNow ( uint32_t  data = 0)
pure virtual

Force an immediate disconnect from this peer.

Parameters
dataOptional user data to send with the disconnect notification.

Implemented in ENetPeerWrapper.

Referenced by Replicator::disconnect().

◆ getAddress()

virtual const IAddress & IPeer::getAddress ( ) const
pure virtual

Get the address of this peer.

Returns
Reference to the peer's address.

Implemented in ENetPeerWrapper.

◆ getData()

virtual void * IPeer::getData ( ) const
pure virtual

Get application-specific data associated with this peer.

Returns
Pointer to user data.

Implemented in ENetPeerWrapper.

◆ getID()

virtual uint32_t IPeer::getID ( ) const
pure virtual

Get a unique identifier for this peer.

Returns
Peer ID or connection index.

Implemented in ENetPeerWrapper.

◆ getRoundTripTime()

virtual uint32_t IPeer::getRoundTripTime ( ) const
pure virtual

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

Returns
RTT in milliseconds.

Implemented in ENetPeerWrapper.

Referenced by Replicator::networkThreadLoop().

◆ getState()

virtual PeerState IPeer::getState ( ) const
pure virtual

Get the current state of this peer.

Returns
The peer's state.

Implemented in ENetPeerWrapper.

Referenced by Replicator::disconnect().

◆ send()

virtual bool IPeer::send ( std::unique_ptr< IPacket packet,
uint8_t  channelID = 0 
)
pure virtual

◆ setData()

virtual void IPeer::setData ( void *  data)
pure virtual

Set application-specific data associated with this peer.

Parameters
dataPointer to user data.

Implemented in ENetPeerWrapper.


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