Buffer<u8> data; // Data of the packet, including headers
float time; // Seconds from buffering the packet or re-sending
float totaltime; // Seconds from buffering the packet
- unsigned int absolute_send_time;
+ u64 absolute_send_time;
Address address; // Sender or destination
unsigned int resend_count;
};
bool reliable;
bool ack;
- OutgoingPacket(u16 peer_id_, u8 channelnum_, SharedBuffer<u8> data_,
+ OutgoingPacket(u16 peer_id_, u8 channelnum_, const SharedBuffer<u8> &data_,
bool reliable_,bool ack_=false):
peer_id(peer_id_),
channelnum(channelnum_),
reliable = reliable_;
}
- void ack(u16 peer_id_, u8 channelnum_, SharedBuffer<u8> data_)
+ void ack(u16 peer_id_, u8 channelnum_, const SharedBuffer<u8> &data_)
{
type = CONCMD_ACK;
peer_id = peer_id_;
reliable = false;
}
- void createPeer(u16 peer_id_, SharedBuffer<u8> data_)
+ void createPeer(u16 peer_id_, const SharedBuffer<u8> &data_)
{
type = CONCMD_CREATE_PEER;
peer_id = peer_id_;
raw = true;
}
- void disableLegacy(u16 peer_id_, SharedBuffer<u8> data_)
+ void disableLegacy(u16 peer_id_, const SharedBuffer<u8> &data_)
{
type = CONCMD_DISABLE_LEGACY;
peer_id = peer_id_;
m_last_rtt(-1.0),
m_usage(0),
m_timeout_counter(0.0),
- m_last_timeout_check(porting::getTimeMs()),
- m_has_sent_with_id(false)
+ m_last_timeout_check(porting::getTimeMs())
{
m_rtt.avg_rtt = -1.0;
m_rtt.jitter_avg = -1.0;
virtual void PutReliableSendCommand(ConnectionCommand &c,
unsigned int max_packet_size) {};
- virtual bool isActive() { return false; };
-
virtual bool getAddress(MTProtocols type, Address& toset) = 0;
+ bool isPendingDeletion()
+ { MutexAutoLock lock(m_exclusive_access_mutex); return m_pending_deletion; };
+
void ResetTimeout()
{MutexAutoLock lock(m_exclusive_access_mutex); m_timeout_counter=0.0; };
bool isTimedOut(float timeout);
- void setSentWithID()
- { MutexAutoLock lock(m_exclusive_access_mutex); m_has_sent_with_id = true; };
-
- bool hasSentWithID()
- { MutexAutoLock lock(m_exclusive_access_mutex); return m_has_sent_with_id; };
-
unsigned int m_increment_packets_remaining;
unsigned int m_increment_bytes_remaining;
virtual void reportRTT(float rtt) {};
void RTTStatistics(float rtt,
- std::string profiler_id="",
- unsigned int num_samples=1000);
+ const std::string &profiler_id = "",
+ unsigned int num_samples = 1000);
bool IncUseCount();
void DecUseCount();
float m_timeout_counter;
u32 m_last_timeout_check;
-
- bool m_has_sent_with_id;
};
class UDPPeer : public Peer
void PutReliableSendCommand(ConnectionCommand &c,
unsigned int max_packet_size);
- bool isActive()
- { return ((hasSentWithID()) && (!m_pending_deletion)); };
-
bool getAddress(MTProtocols type, Address& toset);
void setNonLegacyPeer();
return "Invalid ConnectionEvent";
}
- void dataReceived(u16 peer_id_, SharedBuffer<u8> data_)
+ void dataReceived(u16 peer_id_, const SharedBuffer<u8> &data_)
{
type = CONNEVENT_DATA_RECEIVED;
peer_id = peer_id_;