///////////////////////////////////////////////////////////////////////////////
/// @file deServer.hpp
///
/// @brief 
///
/// @author trajar
///
/// This file is the intellectual property of Novus Delta, LLC.. Usage of the
/// contents of this file is subject to the Destiny3D Member License which
/// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
///
/// This file is distributed "AS IS" without warranty of any kind.  Novus
/// Delta, LLC. does not guarantee the fitness of the contents of this file
/// for any particular purpose.
///
/// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
///
/// <hr>
///                                 Change History
/// <hr>
///
/// @date Jun 2002
/// @author trajar
/// @remarks Creation
///
///////////////////////////////////////////////////////////////////////////////

#ifndef _DESERVER_HPP
#define _DESERVER_HPP

#ifndef		_DENET_HPP
 #include	"deNet.hpp"
#endif

#ifndef		_DENETUSER_HPP
 #include	"deNetUser.hpp"
#endif

#ifndef		_DECONNECTION_HPP
 #include	"deConnection.hpp" 
#endif

typedef class DENET_API deServer : public deNetUser
{
public:

	deServer(void);
	virtual ~deServer(void);

	virtual eNetError	SendToAll( WORD pMsgID, void * pData, DWORD pDataSize, DWORD dwFlags );
	eNetError			AddClient( deConnection * pConn );
	eNetError			RemoveClient( deConnection * pConn );

	virtual deConnection *	GetConnectionByUser( hNetUser pUser );

protected:

	//-------------------------------------------------------------------------------------
	// Override these methods in your deNetUser classes
	//-------------------------------------------------------------------------------------
	virtual eNetError	OnAcceptConnection( deConnectionRequest * pRequest, deConnection * pConn )	= 0;

	//-------------------------------------------------------------------------------------
	// Leave these alone, or call in a overidden method
	//-------------------------------------------------------------------------------------
	virtual eNetError	OnInit( int pType, DWORD dwFlags = NULL );
	virtual eNetError	OnDestroy( DWORD dwFlags = NULL );	
	virtual eNetError	OnCloseConnection( DWORD dwFlags = NULL );
	virtual eNetError	OnConnectionLost( deConnectionLost * pLost );
	virtual eNetError	OnConnectionRequest( deConnectionRequest * pRequest );
	virtual eNetError	OnConnectionReply( deConnectionReply * pReply );

	deConnection **		m_aClients;
	DWORD				m_iNumClients;

} deServer, *pdeServer;

#endif