Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cNetServerUnitTest Class Reference

#include <cNetServer.Tests.h>

Inheritance diagram for GrayLib::cNetServerUnitTest:
GrayLib::cNetServer GrayLib::cProtocolFactories GrayLib::cNetServerGroup Gray::cStreamStats

Public Member Functions

 cNetServerUnitTest (IProtocolFactory &factory, cNetAddress addr)
 
bool InitListenPorts ()
 
bool WaitForClientThread (cThread *pClientThread, TIMESYSD_t nWaitMax=(30 *cTimeSys::k_FREQ))
 
- Public Member Functions inherited from GrayLib::cNetServer
 cNetServer (const char *pszName="NetServer", bool bAsyncEvents=false)
 
virtual ~cNetServer ()
 
const char * get_ServerName () const noexcept
 
ITERATE_t get_ConnectionQty () const noexcept
 
HRESULT AddListenPort (cNetServerPort *pServerPort)
 
HRESULT AddListenPort (const cNetAddress &SockAddr)
 
HRESULT AddListenPort2 (const cNetAddress &SockAddr, OUT cNetServerPortPtr *ppServerPort=nullptr)
 
bool RemoveListenPort (cNetServerPort *pServerPort)
 
ITERATE_t get_ListenPortQty () const noexcept
 
cNetServerPortPtr EnumListenPort (ITERATE_t i) const
 
HRESULT CreateServerStream (const cNetAddress &addr, IProtocolFactory &pf, cNetServerConnectionPtr &rpStream)
 
virtual HRESULT CheckAddressBeforeAccept (const cNetAddress &Addr) const
 
bool InitServer ()
 
void CloseServer ()
 
virtual void OnTickClients () override
 
void OnTickServer (TIMESYSD_t tWaitMax=0)
 
 UNITTEST_FRIEND (cNetServer)
 
- Public Member Functions inherited from GrayLib::cProtocolFactories
bool AddProtocol (IProtocolFactory *pProtocolFactory)
 
HRESULT TestProtocol (const BYTE *pPrefixData, size_t iPrefixLen, OUT IProtocolFactory *&rpProtocolFactory) const
 
- Public Member Functions inherited from GrayLib::cNetServerGroup
 cNetServerGroup (cNetServer &server)
 
virtual ~cNetServerGroup ()
 
const char * get_ServerName () const
 
ITERATE_t get_ClientQty () const
 
bool RemoveClient (cNetServerConnection *pClient)
 
void MoveClientToGroup (cNetServerConnection *pClient)
 
void MoveClientToClose (cNetServerConnection *pClient)
 
- Public Member Functions inherited from Gray::cStreamStats
void Add (const cStreamStats &n)
 

Public Attributes

cNetAddress m_addr
 address and port of this server. Used by client to connect to me. More...
 
- Public Attributes inherited from GrayLib::cNetServer
const char * m_pszServerName
 Server type name. (not host name) More...
 
const bool m_bAsyncEvents
 _WIN32 only. use async callbacks. More...
 
int m_nMaxConnections
 total allowed incoming connections. More...
 
int m_nMaxPerAddr
 max connections per host/address. More...
 
int m_nMaxPerAddrUnresolved
 max unresolved protocol connections per host/address. More...
 
- Public Attributes inherited from GrayLib::cNetServerGroup
cNetServerm_server
 My top level cNetServer owner/parent. More...
 
cValueStatsRate< float > m_TickLatency
 How long did the last OnTickSelect and OnTickClients take ? TIMESYS_t. More...
 
- Public Attributes inherited from Gray::cStreamStats
cStreamStat m_StatOut
 
cStreamStat m_StatInp
 

Additional Inherited Members

- Protected Member Functions inherited from GrayLib::cNetServer
void OnClientCloseComplete ()
 
HRESULT TestProtocolClient (cNetServerConnection *pClient)
 
HRESULT OnEventAccept (cNetServerPort *pListenPort, LSTATUS wError)
 
HRESULT OnClientConnect (cNetServerConnection *pClient)
 
virtual HRESULT OnClientReady (cNetServerConnection *pClient)
 
virtual void OnClientClose (cNetServerConnection *pClient)
 
virtual HRESULT OnClientRead (cNetServerConnection *pClient) override
 
- Protected Member Functions inherited from GrayLib::cNetServerGroup
HRESULT OnClientWrite (cNetServerConnection *pClient)
 
HRESULT OnTickSelect (TIMESYSD_t tWaitMax, cNetSocketSet &readfds, cNetSocketSet &writefds)
 
- Protected Attributes inherited from GrayLib::cNetServer
cNetSystemPtr m_NetSystem
 I use the network. More...
 
cArrayRef< cNetServerThreadm_aThreads
 Alternate threads used to process clients. More...
 
cArraySortHash< cNetServerConnectionm_aConnecting
 My Outgoing connections. From this server to some place. More...
 
cThreadLockArrayHash< cNetServerConnectionm_aClosing
 Call OnClientClose these connections. More...
 
cArraySortHash< cNetServerPortm_aListenPorts
 The server SOCKET(s) we are currently listening on. 1 for each port. More...
 
- Protected Attributes inherited from GrayLib::cProtocolFactories
cArrayPtr< IProtocolFactorym_aProtocols
 array of possible protocols we support. More...
 
- Protected Attributes inherited from GrayLib::cNetServerGroup
cThreadLockArrayHash< cNetServerConnectionm_aConnections
 Collection of active clients. sorted by socket id. More...
 

Detailed Description

a unit testing framework for a cNetServer protocol(s).

Constructor & Destructor Documentation

◆ cNetServerUnitTest()

GrayLib::cNetServerUnitTest::cNetServerUnitTest ( IProtocolFactory factory,
cNetAddress  addr 
)

Member Function Documentation

◆ InitListenPorts()

bool GrayLib::cNetServerUnitTest::InitListenPorts ( )

◆ WaitForClientThread()

bool GrayLib::cNetServerUnitTest::WaitForClientThread ( cThread pClientThread,
TIMESYSD_t  nWaitMax = (30 * cTimeSys::k_FREQ) 
)

Wait for the client thread in the test to disconnect or time is expired.

  • nWaitMax = 2*cTimeSys::k_FREQ

Member Data Documentation

◆ m_addr

cNetAddress GrayLib::cNetServerUnitTest::m_addr

address and port of this server. Used by client to connect to me.


The documentation for this class was generated from the following files: