//---------------------------------------------------------------------------

#ifndef ClientSessionManagerFH
#define ClientSessionManagerFH
//---------------------------------------------------------------------------
#include <map>
#include "ITSLibF.h"
#include "ClientSessionF.h"
//---------------------------------------------------------------------------
#define USE_POOL    1
//---------------------------------------------------------------------------

class TClientSessionManager
{
public:
	TClientSessionManager();
	~TClientSessionManager();

private:
	typedef std::map<SOCKET, TClientSession*> TClientSessionList;

    TItsMap<int, TClientSession*> FLists;

	TClientSessionList  FClientSessionList;
	DWORD               FLastTick;

public:
	void CollectGarbageSessions();
	void CheckCommandTimeoutSessions();

	TClientSession* CreateClientSession(SOCKET ASock, SOCKADDR_IN* ASockAddr);
    TClientSession* FindClientSession(SOCKET ASock);
	void OnPeriodWork() ;
	void SendFlushAllClient();
    void Init(int APoolSize);
    void CloseAll();
};
//---------------------------------------------------------------------------
extern PACKAGE TClientSessionManager *ClientSessionManager;
//---------------------------------------------------------------------------

#endif
