Blob Blame Raw
#ifndef UDPSENDQUEUE_H
#define UDPSENDQUEUE_H


#include "common.h"


class Connection;


class UdpSendQueue {
public:
	struct Entry {
		Entry *prev, *next;
		Time resendTime;
		unsigned int index;
		unsigned short size;
		unsigned char data[PACKET_SIZE];
	};
	
public:
	Connection &connection;
private:
	Time nextSendTime;
	Time nextPartialSendTime;
	bool finalEntryAdded;
	unsigned int nextIndex;
	
	Entry *freeFirst;
	Entry *busyFirst, *busyLast;
	Entry entries[PACKETS_COUNT];
	
	Entry* allocEntry();
	void freeEntry(Entry *e);
	
public:
	explicit UdpSendQueue(Connection &connection);
	~UdpSendQueue();
	
	void confirm(unsigned int index, const unsigned char *bits, unsigned int bitsCount);
	bool sendUdp();
};


#endif