};
typedef enum MTProtocols {
- PRIMARY,
- UDP,
- MINETEST_RELIABLE_UDP
+ MTP_PRIMARY,
+ MTP_UDP,
+ MTP_MINETEST_RELIABLE_UDP
} MTProtocols;
#define SEQNUM_MAX 65535
struct BufferedPacket
{
BufferedPacket(u8 *a_data, u32 a_size):
- data(a_data, a_size), time(0.0), totaltime(0.0), absolute_send_time(-1)
+ data(a_data, a_size), time(0.0), totaltime(0.0), absolute_send_time(-1),
+ resend_count(0)
{}
BufferedPacket(u32 a_size):
- data(a_size), time(0.0), totaltime(0.0), absolute_send_time(-1)
+ data(a_size), time(0.0), totaltime(0.0), absolute_send_time(-1),
+ resend_count(0)
{}
SharedBuffer<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;
Address address; // Sender or destination
+ unsigned int resend_count;
};
// This adds the base headers to the data and makes a packet out of it
public:
friend class UDPPeer;
- ConnectionSendThread(Connection* parent,
- unsigned int max_packet_size, float timeout);
+ ConnectionSendThread(unsigned int max_packet_size, float timeout);
void * Thread ();
void Trigger();
+ void setParent(Connection* parent) {
+ assert(parent != NULL);
+ m_connection = parent;
+ }
+
void setPeerTimeout(float peer_timeout)
{ m_timeout = peer_timeout; }
class ConnectionReceiveThread : public JThread {
public:
- ConnectionReceiveThread(Connection* parent,
- unsigned int max_packet_size);
+ ConnectionReceiveThread(unsigned int max_packet_size);
void * Thread ();
+ void setParent(Connection* parent) {
+ assert(parent != NULL);
+ m_connection = parent;
+ }
+
private:
void receive ();