Blob Blame Raw
#ifndef CONNECTION_H
#define CONNECTION_H


#include "tcpqueue.h"
#include "udpsendqueue.h"
#include "udprecvqueue.h"


class Tunnel;


class Connection {
public:
	struct Args {
		Tunnel &tunnel;
		const ConnId &id;
		int tcpSockId;
		inline Args(Tunnel &tunnel, const ConnId &id, int tcpSockId):
			tunnel(tunnel), id(id), tcpSockId(tcpSockId) { }
	};
	
	Tunnel &tunnel;
	const ConnId id;
	int tcpSockId;
	bool udpActive;
	
	Time lastUdpInputTime;
	Time lastUdpOutputTime;
	
	TcpQueue tcpSendQueue;
	TcpQueue tcpRecvQueue;
	UdpSendQueue udpSendQueue;
	UdpRecvQueue udpRecvQueue;

	explicit Connection(const Args &args);
	~Connection();
	
	bool wantReadFromTcp() const;
	bool wantWriteToTcp() const;
	void whenWriteToUdp(Time &t) const;
};


#endif