Blob Blame Raw
#ifndef TUNNEL_H
#define TUNNEL_H


#include "socket.h"
#include "connection.h"

#include <map>
#include <set>



class Tunnel {
public:
	typedef std::map<ConnId, Connection> ConnMap;
	typedef std::set<ConnId> ConnSet;
	
public:
	Time time;
	Time udpSendDuration;
	Time udpPartialSendDuration;
	Time udpResendDuration;
	Time udpConfirmDuration;
	Time pollDuration;
	
	ConnMap connections;
	ConnSet termQueue;
	
private:
	Poll poll;
	int udpSockId;
	int tcpSockId;
	Address remoteUdpAddress;
	Address remoteTcpAddress;
	Time nextTermSendTime;
	
public:
	Tunnel();
	~Tunnel();
	
	bool initUdpServer(const Address &address, const Address &remoteTcpAddress);
	bool initTcpServer(const Address &address, const Address &remoteUdpAddress);
	
	void closeTcpServer();
	void closeUdpServer();
	void close();
	
	bool recvUdpPacket();
	void sendUdpPacket(const Address &address, const Packet &packet);
	bool iteration();
	
	void run();
};


#endif