#pragma once
#ifndef CHHSocketNotifier_h
#define CHHSocketNotifier_h
#include <map>
#include "CHHSocket.h"
#include "ASyncronizationClass.h"
namespace CoreFW
{
typedef std::map< int, CHHSocket* > TCHHSocketMap ;
class CORE_DLL_DECLARATION_SPECIFIER CHHSocketNotifier
{
public:
CHHSocketNotifier() ;
virtual ~CHHSocketNotifier() ;
FW_RETURN_TYPE Register( CHHSocket *pSocket ) ;
FW_RETURN_TYPE Unregister( CHHSocket *pSocket ) ;
FW_RETURN_TYPE Start( unsigned long ulTimoutPeriodInMSec ) ;
FW_RETURN_TYPE Stop() ;
void SetTimeoutPeriodInMSec( unsigned long ulTimoutPeriodInMSec ) ;
private:
static void SocketNotifierThread( void *pParam ) ;
protected:
bool IsSocketSet( int iSocketHandle, fd_set *pstFDSet ) ;
bool IsSocketClosed( int iSocketHandle ) ;
void NotifySocketEvent( EnumSocketNotificationType eSocketNotificationType,
CHHSocket *pSocket,
const char *pstrData, int iDataLength,
CHHSocketException *pSocketException ) ;
protected:
virtual void ProcessNotification( int iNoOfSocketSetted, fd_set *pstFDSet ) = 0 ;
protected:
fd_set m_FDSet ;
TCHHSocketMap m_SocketMap ;
ASyncronizationClass *m_pSocketSyncObject ;
unsigned long m_ulTimoutPeriodInMSec ;
bool m_bNotifierThreadRunning ;
} ;
inline void CHHSocketNotifier::SetTimeoutPeriodInMSec( unsigned long ulTimoutPeriodInMSec )
{
m_ulTimoutPeriodInMSec = ulTimoutPeriodInMSec ;
}
} // End namespace
#endif