Luanti 5.16.0-dev
Loading...
Searching...
No Matches
con::Connection Class Referencefinal

#include <impl.h>

Inheritance diagram for con::Connection:
Collaboration diagram for con::Connection:

Public Member Functions

 Connection (u32 max_packet_size, float timeout, bool ipv6, PeerHandler *peerhandler)
 ~Connection ()
ConnectionEventPtr waitEvent (u32 timeout_ms)
void putCommand (ConnectionCommandPtr c)
void Serve (Address bind_addr)
void Connect (Address address)
bool Connected ()
void Disconnect ()
bool ReceiveTimeoutMs (NetworkPacket *pkt, u32 timeout_ms)
void Send (session_t peer_id, u8 channelnum, NetworkPacket *pkt, bool reliable)
session_t GetPeerID () const
Address GetPeerAddress (session_t peer_id)
float getPeerStat (session_t peer_id, rtt_stat_type type)
float getLocalStat (rate_stat_type type)
u32 GetProtocolID () const
const std::string getDesc ()
void DisconnectPeer (session_t peer_id)
Public Member Functions inherited from con::IConnection
virtual ~IConnection ()=default
bool TryReceive (NetworkPacket *pkt)

Protected Member Functions

PeerHelper getPeerNoEx (session_t peer_id)
session_t lookupPeer (const Address &sender)
session_t createPeer (const Address &sender, int fd)
UDPPeercreateServerPeer (const Address &sender)
bool deletePeer (session_t peer_id, bool timeout)
void SetPeerID (session_t id)
void doResendOne (session_t peer_id)
void sendAck (session_t peer_id, u8 channelnum, u16 seqnum)
std::vector< session_tgetPeerIDs ()
u32 getActiveCount ()
void putEvent (ConnectionEventPtr e)
void TriggerSend ()
bool ConnectedToServer ()

Protected Attributes

UDPSocket m_udpSocket
MutexedQueue< ConnectionCommandPtrm_command_queue

Private Attributes

MutexedQueue< ConnectionEventPtrm_event_queue
session_t m_peer_id = 0
u32 m_protocol_id
std::map< session_t, Peer * > m_peers
std::vector< session_tm_peer_ids
std::mutex m_peers_mutex
std::unique_ptr< ConnectionSendThreadm_sendThread
std::unique_ptr< ConnectionReceiveThreadm_receiveThread
std::mutex m_info_mutex
PeerHandlerm_bc_peerhandler
std::atomic< bool > m_shutting_down = false

Friends

class ConnectionSendThread
class ConnectionReceiveThread

Constructor & Destructor Documentation

◆ Connection()

con::Connection::Connection ( u32 max_packet_size,
float timeout,
bool ipv6,
PeerHandler * peerhandler )

References ConnectionReceiveThread, ConnectionSendThread, m_bc_peerhandler, m_protocol_id, m_receiveThread, m_sendThread, m_udpSocket, and PROTOCOL_ID.

Here is the call graph for this function:

◆ ~Connection()

con::Connection::~Connection ( )

Member Function Documentation

◆ Connect()

void con::Connection::Connect ( Address address)
virtual

Implements con::IConnection.

References con::ConnectionCommand::connect(), and putCommand().

Here is the call graph for this function:

◆ Connected()

bool con::Connection::Connected ( )
virtual

◆ ConnectedToServer()

bool con::Connection::ConnectedToServer ( )
inlineprotected

References getPeerNoEx(), and PEER_ID_SERVER.

Referenced by createServerPeer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createPeer()

session_t con::Connection::createPeer ( const Address & sender,
int fd )
protected

References con::CONTROLTYPE_SET_PEER_ID, con::ConnectionCommand::createPeer(), dout_con, errorstream, getDesc(), con::IPeer::id, LOG, m_peer_ids, m_peers, m_peers_mutex, MAX_UDP_PEERS, myrand_range(), con::PACKET_TYPE_CONTROL, PEER_ID_INEXISTENT, con::ConnectionEvent::peerAdded(), putCommand(), putEvent(), writeU16(), and writeU8().

Here is the call graph for this function:

◆ createServerPeer()

UDPPeer * con::Connection::createServerPeer ( const Address & sender)
protected

References ConnectedToServer(), con::IPeer::id, m_peer_ids, m_peers, m_peers_mutex, PEER_ID_SERVER, and con::Peer::SetFullyOpen().

Here is the call graph for this function:

◆ deletePeer()

bool con::Connection::deletePeer ( session_t peer_id,
bool timeout )
protected

References con::Peer::Drop(), con::IPeer::getAddress(), m_peer_ids, m_peers, m_peers_mutex, con::ConnectionEvent::peerRemoved(), and putEvent().

Here is the call graph for this function:

◆ Disconnect()

void con::Connection::Disconnect ( )
virtual

Implements con::IConnection.

References con::ConnectionCommand::disconnect(), and putCommand().

Here is the call graph for this function:

◆ DisconnectPeer()

void con::Connection::DisconnectPeer ( session_t peer_id)
virtual

Implements con::IConnection.

References con::ConnectionCommand::disconnect_peer(), and putCommand().

Here is the call graph for this function:

◆ doResendOne()

void con::Connection::doResendOne ( session_t peer_id)
protected

References PEER_ID_INEXISTENT, putCommand(), and con::ConnectionCommand::resend_one().

Here is the call graph for this function:

◆ getActiveCount()

u32 con::Connection::getActiveCount ( )
protected

References con::Peer::isHalfOpen(), con::Peer::isPendingDeletion(), m_peers, and m_peers_mutex.

Here is the call graph for this function:

◆ getDesc()

const std::string con::Connection::getDesc ( )

References _, itos(), m_info_mutex, m_peer_id, and m_udpSocket.

Referenced by createPeer(), ReceiveTimeoutMs(), and sendAck().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLocalStat()

float con::Connection::getLocalStat ( rate_stat_type type)
virtual

Implements con::IConnection.

References con::AVG_DL_RATE, con::AVG_INC_RATE, con::AVG_LOSS_RATE, con::CUR_DL_RATE, con::CUR_INC_RATE, con::CUR_LOSS_RATE, FATAL_ERROR, FATAL_ERROR_IF, getPeerNoEx(), and PEER_ID_SERVER.

Here is the call graph for this function:

◆ GetPeerAddress()

Address con::Connection::GetPeerAddress ( session_t peer_id)
virtual

Implements con::IConnection.

References con::IPeer::getAddress(), and getPeerNoEx().

Here is the call graph for this function:

◆ GetPeerID()

session_t con::Connection::GetPeerID ( ) const
inlinevirtual

Implements con::IConnection.

References m_peer_id.

◆ getPeerIDs()

std::vector< session_t > con::Connection::getPeerIDs ( )
inlineprotected

References m_peer_ids, and m_peers_mutex.

◆ getPeerNoEx()

PeerHelper con::Connection::getPeerNoEx ( session_t peer_id)
protected

References FATAL_ERROR_IF, m_peers, and m_peers_mutex.

Referenced by ConnectedToServer(), getLocalStat(), GetPeerAddress(), and getPeerStat().

Here is the caller graph for this function:

◆ getPeerStat()

float con::Connection::getPeerStat ( session_t peer_id,
rtt_stat_type type )
virtual

Implements con::IConnection.

References getPeerNoEx(), and con::Peer::getStat().

Here is the call graph for this function:

◆ GetProtocolID()

u32 con::Connection::GetProtocolID ( ) const
inline

References m_protocol_id.

◆ lookupPeer()

session_t con::Connection::lookupPeer ( const Address & sender)
protected

References con::IPeer::getAddress(), con::IPeer::id, con::Peer::isPendingDeletion(), m_peers, m_peers_mutex, and PEER_ID_INEXISTENT.

Here is the call graph for this function:

◆ putCommand()

void con::Connection::putCommand ( ConnectionCommandPtr c)

References m_command_queue, m_sendThread, and m_shutting_down.

Referenced by Connect(), createPeer(), Disconnect(), DisconnectPeer(), doResendOne(), Send(), sendAck(), Serve(), and SetPeerID().

Here is the caller graph for this function:

◆ putEvent()

void con::Connection::putEvent ( ConnectionEventPtr e)
protected

References con::CONNEVENT_NONE, and m_event_queue.

Referenced by createPeer(), and deletePeer().

Here is the caller graph for this function:

◆ ReceiveTimeoutMs()

◆ Send()

void con::Connection::Send ( session_t peer_id,
u8 channelnum,
NetworkPacket * pkt,
bool reliable )
virtual

Implements con::IConnection.

References CHANNEL_COUNT, FATAL_ERROR, NetworkPacket::getCommand(), NetworkPacket::getSize(), MAX_RELIABLE_WINDOW_SIZE, putCommand(), and con::ConnectionCommand::send().

Here is the call graph for this function:

◆ sendAck()

void con::Connection::sendAck ( session_t peer_id,
u8 channelnum,
u16 seqnum )
protected

References con::ConnectionCommand::ack(), CHANNEL_COUNT, con::CONTROLTYPE_ACK, dout_con, getDesc(), LOG, m_sendThread, con::PACKET_TYPE_CONTROL, putCommand(), writeU16(), and writeU8().

Here is the call graph for this function:

◆ Serve()

void con::Connection::Serve ( Address bind_addr)
virtual

Implements con::IConnection.

References putCommand(), and con::ConnectionCommand::serve().

Here is the call graph for this function:

◆ SetPeerID()

void con::Connection::SetPeerID ( session_t id)
protected

References m_peer_id, PEER_ID_INEXISTENT, con::ConnectionCommand::peer_id_set(), and putCommand().

Here is the call graph for this function:

◆ TriggerSend()

void con::Connection::TriggerSend ( )
protected

References m_sendThread.

◆ waitEvent()

ConnectionEventPtr con::Connection::waitEvent ( u32 timeout_ms)

References con::CONNEVENT_NONE, con::ConnectionEvent::create(), and m_event_queue.

Referenced by ReceiveTimeoutMs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConnectionReceiveThread

friend class ConnectionReceiveThread
friend

◆ ConnectionSendThread

friend class ConnectionSendThread
friend

References ConnectionSendThread.

Referenced by Connection(), and ConnectionSendThread.

Member Data Documentation

◆ m_bc_peerhandler

PeerHandler* con::Connection::m_bc_peerhandler
private

Referenced by Connection(), and ReceiveTimeoutMs().

◆ m_command_queue

MutexedQueue<ConnectionCommandPtr> con::Connection::m_command_queue
protected

Referenced by putCommand().

◆ m_event_queue

MutexedQueue<ConnectionEventPtr> con::Connection::m_event_queue
private

Referenced by putEvent(), and waitEvent().

◆ m_info_mutex

std::mutex con::Connection::m_info_mutex
mutableprivate

Referenced by getDesc().

◆ m_peer_id

session_t con::Connection::m_peer_id = 0
private

◆ m_peer_ids

std::vector<session_t> con::Connection::m_peer_ids
private

◆ m_peers

std::map<session_t, Peer *> con::Connection::m_peers
private

◆ m_peers_mutex

std::mutex con::Connection::m_peers_mutex
private

◆ m_protocol_id

u32 con::Connection::m_protocol_id
private

Referenced by Connection(), and GetProtocolID().

◆ m_receiveThread

std::unique_ptr<ConnectionReceiveThread> con::Connection::m_receiveThread
private

Referenced by Connection(), and ~Connection().

◆ m_sendThread

std::unique_ptr<ConnectionSendThread> con::Connection::m_sendThread
private

◆ m_shutting_down

std::atomic<bool> con::Connection::m_shutting_down = false
private

Referenced by ~Connection(), and putCommand().

◆ m_udpSocket

UDPSocket con::Connection::m_udpSocket
protected

Referenced by Connection(), and getDesc().


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