Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
con::ConnectionSendThread Class Reference

#include <threads.h>

+ Inheritance diagram for con::ConnectionSendThread:
+ Collaboration diagram for con::ConnectionSendThread:

Public Member Functions

 ConnectionSendThread (unsigned int max_packet_size, float timeout)
 
void * run ()
 
void Trigger ()
 
void setParent (Connection *parent)
 
void setPeerTimeout (float peer_timeout)
 
- Public Member Functions inherited from Thread
 Thread (const std::string &name="")
 
virtual ~Thread ()
 
bool start ()
 
bool stop ()
 
bool wait ()
 
bool isCurrentThread ()
 
bool isRunning ()
 
bool stopRequested ()
 
std::thread::id getThreadId ()
 
bool getReturnValue (void **ret)
 
bool bindToProcessor (unsigned int proc_number)
 
bool setPriority (int prio)
 

Private Member Functions

void runTimeouts (float dtime, u32 peer_packet_quota)
 
void resendReliable (Channel &channel, const BufferedPacket *k, float resend_timeout)
 
void rawSend (const BufferedPacket *p)
 
bool rawSendAsPacket (session_t peer_id, u8 channelnum, const SharedBuffer< u8 > &data, bool reliable)
 
void processReliableCommand (ConnectionCommandPtr &c)
 
void processNonReliableCommand (ConnectionCommandPtr &c)
 
void serve (Address bind_address)
 
void connect (Address address)
 
void disconnect ()
 
void disconnect_peer (session_t peer_id)
 
void send (session_t peer_id, u8 channelnum, const SharedBuffer< u8 > &data)
 
void sendReliable (ConnectionCommandPtr &c)
 
void sendToAll (u8 channelnum, const SharedBuffer< u8 > &data)
 
void sendToAllReliable (ConnectionCommandPtr &c)
 
void sendPackets (float dtime, u32 peer_packet_quota)
 
void sendAsPacket (session_t peer_id, u8 channelnum, const SharedBuffer< u8 > &data, bool ack=false)
 
void sendAsPacketReliable (BufferedPacketPtr &p, Channel *channel)
 
bool packetsQueued ()
 

Private Attributes

Connectionm_connection = nullptr
 
unsigned int m_max_packet_size
 
float m_timeout
 
std::queue< OutgoingPacketm_outgoing_queue
 
Semaphore m_send_sleep_semaphore
 
unsigned int m_iteration_packets_avaialble
 
unsigned int m_max_data_packets_per_iteration
 
unsigned int m_max_packets_requeued = 256
 

Friends

class UDPPeer
 

Additional Inherited Members

- Static Public Member Functions inherited from Thread
static ThreadgetCurrentThread ()
 
static void setName (const std::string &name)
 
static unsigned int getNumberOfProcessors ()
 
- Protected Attributes inherited from Thread
std::string m_name
 

Constructor & Destructor Documentation

◆ ConnectionSendThread()

con::ConnectionSendThread::ConnectionSendThread ( unsigned int max_packet_size,
float timeout )

References Settings::getLayer(), m_max_data_packets_per_iteration, MPPI_SETTING, MYMAX, SL_DEFAULTS, and warningstream.

+ Here is the call graph for this function:

Member Function Documentation

◆ connect()

void con::ConnectionSendThread::connect ( Address address)
private

References con::Peer::address, UDPSocket::Bind(), con::Connection::createServerPeer(), dout_con, con::Connection::getDesc(), con::IPeer::id, Address::isIPv6(), m_connection, con::Connection::m_udpSocket, PEER_ID_INEXISTENT, PEER_ID_SERVER, con::ConnectionEvent::peerAdded(), Address::print(), con::Connection::putEvent(), con::Connection::Send(), Address::setAddress(), and con::Connection::SetPeerID().

Referenced by processNonReliableCommand().

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

◆ disconnect()

void con::ConnectionSendThread::disconnect ( )
private

References CONTROLTYPE_DISCO, dout_con, con::Connection::getDesc(), con::Connection::getPeerIDs(), LOG, m_connection, con::PACKET_TYPE_CONTROL, sendAsPacket(), and writeU8().

Referenced by processNonReliableCommand().

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

◆ disconnect_peer()

void con::ConnectionSendThread::disconnect_peer ( session_t peer_id)
private

References CONTROLTYPE_DISCO, dout_con, con::Connection::getDesc(), con::Connection::getPeerNoEx(), LOG, m_connection, con::PACKET_TYPE_CONTROL, sendAsPacket(), and writeU8().

Referenced by processNonReliableCommand().

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

◆ packetsQueued()

bool con::ConnectionSendThread::packetsQueued ( )
private

References con::Connection::getPeerIDs(), con::Connection::getPeerNoEx(), m_connection, and m_outgoing_queue.

Referenced by run().

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

◆ processNonReliableCommand()

void con::ConnectionSendThread::processNonReliableCommand ( ConnectionCommandPtr & c)
private

References con::ConnectionCommand::address, con::ConnectionCommand::channelnum, con::CONCMD_ACK, con::CONCMD_CREATE_PEER, con::CONNCMD_CONNECT, con::CONNCMD_DISCONNECT, con::CONNCMD_DISCONNECT_PEER, con::CONNCMD_NONE, con::CONNCMD_RESEND_ONE, con::CONNCMD_SEND, con::CONNCMD_SEND_TO_ALL, con::CONNCMD_SERVE, connect(), con::ConnectionCommand::data, disconnect(), disconnect_peer(), dout_con, FATAL_ERROR, con::Connection::getDesc(), LOG, m_connection, con::ConnectionCommand::peer_id, con::ConnectionCommand::reliable, send(), sendAsPacket(), sendToAll(), Address::serializeString(), serve(), and con::ConnectionCommand::type.

Referenced by run().

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

◆ processReliableCommand()

void con::ConnectionSendThread::processReliableCommand ( ConnectionCommandPtr & c)
private

References con::CONCMD_ACK, con::CONCMD_CREATE_PEER, con::CONNCMD_CONNECT, con::CONNCMD_DISCONNECT, con::CONNCMD_NONE, con::CONNCMD_RESEND_ONE, con::CONNCMD_SEND, con::CONNCMD_SEND_TO_ALL, con::CONNCMD_SERVE, dout_con, FATAL_ERROR, con::Connection::getDesc(), con::Connection::getPeerNoEx(), con::ReliablePacketBuffer::getResend(), LOG, m_connection, con::Channel::outgoing_reliables_sent, rawSendAsPacket(), resendReliable(), sendReliable(), and sendToAllReliable().

Referenced by run().

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

◆ rawSend()

void con::ConnectionSendThread::rawSend ( const BufferedPacket * p)
private

References derr_con, con::Connection::getDesc(), LOG, m_connection, con::Connection::m_udpSocket, p(), UDPSocket::Send(), and BaseException::what().

Referenced by rawSendAsPacket(), resendReliable(), and sendAsPacketReliable().

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

◆ rawSendAsPacket()

bool con::ConnectionSendThread::rawSendAsPacket ( session_t peer_id,
u8 channelnum,
const SharedBuffer< u8 > & data,
bool reliable )
private

References dout_con, errorstream, con::IPeer::getAddress(), con::Connection::getDesc(), con::Channel::getOutgoingSequenceNumber(), con::Connection::GetPeerID(), con::Connection::getPeerNoEx(), con::Connection::GetProtocolID(), con::Channel::getWindowSize(), LOG, m_connection, con::makePacket(), con::makeReliablePacket(), con::Channel::outgoing_reliables_sent, p(), con::Channel::queued_reliables, rawSend(), sendAsPacketReliable(), and con::ReliablePacketBuffer::size().

Referenced by processReliableCommand(), runTimeouts(), and sendPackets().

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

◆ resendReliable()

void con::ConnectionSendThread::resendReliable ( Channel & channel,
const BufferedPacket * k,
float resend_timeout )
private

References con::BufferedPacket::address, con::BufferedPacket::data, derr_con, con::Connection::getDesc(), con::BufferedPacket::getSeqnum(), m_connection, rawSend(), con::readChannel(), con::BufferedPacket::resend_count, Address::serializeString(), con::BufferedPacket::size(), and con::Channel::UpdateBytesLost().

Referenced by processReliableCommand(), and runTimeouts().

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

◆ run()

◆ runTimeouts()

void con::ConnectionSendThread::runTimeouts ( float dtime,
u32 peer_packet_quota )
private

◆ send()

void con::ConnectionSendThread::send ( session_t peer_id,
u8 channelnum,
const SharedBuffer< u8 > & data )
private

References BASE_HEADER_SIZE, CHANNEL_COUNT, dout_con, con::Connection::getDesc(), con::Peer::getNextSplitSequenceNumber(), con::Connection::getPeerNoEx(), SharedBuffer< T >::getSize(), LOG, m_connection, m_max_packet_size, con::makeAutoSplitPacket(), sendAsPacket(), and con::Peer::setNextSplitSequenceNumber().

Referenced by processNonReliableCommand(), and sendToAll().

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

◆ sendAsPacket()

void con::ConnectionSendThread::sendAsPacket ( session_t peer_id,
u8 channelnum,
const SharedBuffer< u8 > & data,
bool ack = false )
private

References m_outgoing_queue.

Referenced by disconnect(), disconnect_peer(), processNonReliableCommand(), and send().

+ Here is the caller graph for this function:

◆ sendAsPacketReliable()

void con::ConnectionSendThread::sendAsPacketReliable ( BufferedPacketPtr & p,
Channel * channel )
private

References derr_con, con::Connection::getDesc(), porting::getTimeMs(), con::ReliablePacketBuffer::insert(), LOG, m_connection, MAX_RELIABLE_WINDOW_SIZE, con::Channel::outgoing_reliables_sent, p(), rawSend(), and con::Channel::readOutgoingSequenceNumber().

Referenced by rawSendAsPacket(), and sendPackets().

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

◆ sendPackets()

◆ sendReliable()

void con::ConnectionSendThread::sendReliable ( ConnectionCommandPtr & c)
private

References con::Connection::getPeerNoEx(), m_connection, m_max_packet_size, and con::Peer::PutReliableSendCommand().

Referenced by processReliableCommand().

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

◆ sendToAll()

void con::ConnectionSendThread::sendToAll ( u8 channelnum,
const SharedBuffer< u8 > & data )
private

References con::Connection::getPeerIDs(), m_connection, and send().

Referenced by processNonReliableCommand().

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

◆ sendToAllReliable()

void con::ConnectionSendThread::sendToAllReliable ( ConnectionCommandPtr & c)
private

References con::Connection::getPeerIDs(), con::Connection::getPeerNoEx(), m_connection, m_max_packet_size, and con::Peer::PutReliableSendCommand().

Referenced by processReliableCommand().

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

◆ serve()

void con::ConnectionSendThread::serve ( Address bind_address)
private

References UDPSocket::Bind(), con::ConnectionEvent::bindFailed(), dout_con, con::Connection::getDesc(), LOG, m_connection, con::Connection::m_udpSocket, PEER_ID_SERVER, con::Connection::putEvent(), Address::serializeString(), and con::Connection::SetPeerID().

Referenced by processNonReliableCommand().

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

◆ setParent()

void con::ConnectionSendThread::setParent ( Connection * parent)
inline

References m_connection.

◆ setPeerTimeout()

void con::ConnectionSendThread::setPeerTimeout ( float peer_timeout)
inline

References m_timeout.

◆ Trigger()

void con::ConnectionSendThread::Trigger ( )

References m_send_sleep_semaphore, and Semaphore::post().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ UDPPeer

friend class UDPPeer
friend

Member Data Documentation

◆ m_connection

◆ m_iteration_packets_avaialble

unsigned int con::ConnectionSendThread::m_iteration_packets_avaialble
private

Referenced by run(), and runTimeouts().

◆ m_max_data_packets_per_iteration

unsigned int con::ConnectionSendThread::m_max_data_packets_per_iteration
private

Referenced by ConnectionSendThread(), and run().

◆ m_max_packet_size

unsigned int con::ConnectionSendThread::m_max_packet_size
private

◆ m_max_packets_requeued

unsigned int con::ConnectionSendThread::m_max_packets_requeued = 256
private

Referenced by runTimeouts().

◆ m_outgoing_queue

std::queue<OutgoingPacket> con::ConnectionSendThread::m_outgoing_queue
private

◆ m_send_sleep_semaphore

Semaphore con::ConnectionSendThread::m_send_sleep_semaphore
private

Referenced by run(), and Trigger().

◆ m_timeout

float con::ConnectionSendThread::m_timeout
private

Referenced by runTimeouts(), and setPeerTimeout().


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