5 #ifndef _INC_cNetServer_H
6 #define _INC_cNetServer_H
13 #include "../Thread/cThread.h"
14 #include "../Math/cValueStats.h"
74 const char* get_ServerName()
const;
95 virtual HRESULT onEventRead()
override;
98 virtual void OnClose()
override;
100 virtual void Close()
override;
124 virtual void OnTickClients();
130 const char* get_ServerName()
const;
135 return m_aConnections.
GetSize();
149 virtual bool ThreadTick()
override;
152 UINT get_LoadScore()
const;
186 void OnClientCloseComplete();
198 cNetServer(
const char* pszName =
"NetServer",
bool bAsyncEvents =
false);
203 return m_pszServerName;
209 return m_aListenPorts.
GetSize() + m_aConnections.GetSize() + m_aConnecting.
GetSize();
220 return m_aListenPorts.
GetSize();
225 return m_aListenPorts[i];
232 bool OnEvent(SOCKET hSocket, WORD wEvent,
LSTATUS wError);
238 virtual void OnTickClients()
override;
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define ASSERT(exp)
Definition: cDebugAssert.h:87
Definition: cNetAddr.h:31
Definition: cNetServer.h:52
const cNetAddress m_addrPeer
The peer (source/remote) connection address. if i care.
Definition: cNetServer.h:65
HASHCODE_t get_HashCode() const noexcept
Definition: cNetServer.h:76
cNetServerPortPtr m_pListenPort
the server port i connected on. (if incoming connection, nullptr if outgoing connection)(used to reso...
Definition: cNetServer.h:63
STDMETHOD_(HASHCODE_t, get_HashCodeX)() const noexcept override
Definition: cNetServer.h:81
cProtocolStreamPtr m_pProtocol
resolved to talk this protocol. nullptr = protocol not resolved yet.
Definition: cNetServer.h:68
STDMETHOD_(cString, get_Name)() const override
STDMETHOD_(cStringA, get_SymName)() const
Definition: cNetServer.h:87
IUNKNOWN_DISAMBIG(cRefBase)
cNetServerGroup * m_pServerGroup
Assigned to this group/thread for processing.
Definition: cNetServer.h:62
Definition: cNetServer.h:107
cNetServer & m_server
My top level cNetServer owner/parent.
Definition: cNetServer.h:114
cThreadLockArrayHash< cNetServerConnection > m_aConnections
Collection of active clients. sorted by socket id.
Definition: cNetServer.h:118
ITERATE_t get_ClientQty() const
Definition: cNetServer.h:132
cValueStatsRate< float > m_TickLatency
How long did the last OnTickSelect and OnTickClients take ? TIMESYS_t.
Definition: cNetServer.h:115
Definition: cNetServer.h:26
HASHCODE_t get_HashCode() const noexcept
Definition: cNetServer.h:41
cProtocolFactories m_Factories
What protocols does this port support/prefer ?
Definition: cNetServer.h:34
cNetSocket m_Socket
Open listen socket.
Definition: cNetServer.h:35
cNetAddress m_SockAddr
What local address am i bound to? (or should be bound to) may be all adapter/interfaces for the same ...
Definition: cNetServer.h:33
Definition: cNetServer.h:144
Definition: cNetServer.h:157
ITERATE_t get_ListenPortQty() const noexcept
Definition: cNetServer.h:217
cArrayRef< cNetServerThread > m_aThreads
Alternate threads used to process clients.
Definition: cNetServer.h:180
const char * m_pszServerName
Server type name. (not host name)
Definition: cNetServer.h:170
int m_nMaxConnections
total allowed incoming connections.
Definition: cNetServer.h:173
int m_nMaxPerAddr
max connections per host/address.
Definition: cNetServer.h:174
cArraySortHash< cNetServerConnection > m_aConnecting
My Outgoing connections. From this server to some place.
Definition: cNetServer.h:181
UNITTEST_FRIEND(cNetServer)
cNetServerPortPtr EnumListenPort(ITERATE_t i) const
Definition: cNetServer.h:222
cNetSystemPtr m_NetSystem
I use the network.
Definition: cNetServer.h:178
ITERATE_t get_ConnectionQty() const noexcept
Definition: cNetServer.h:206
cThreadLockArrayHash< cNetServerConnection > m_aClosing
Call OnClientClose these connections.
Definition: cNetServer.h:182
const char * get_ServerName() const noexcept
Definition: cNetServer.h:201
cArraySortHash< cNetServerPort > m_aListenPorts
The server SOCKET(s) we are currently listening on. 1 for each port.
Definition: cNetServer.h:183
int m_nMaxPerAddrUnresolved
max unresolved protocol connections per host/address.
Definition: cNetServer.h:175
const bool m_bAsyncEvents
_WIN32 only. use async callbacks.
Definition: cNetServer.h:171
Definition: cNetSocketSet.h:18
Definition: cNetSocket.h:185
HASHCODE_t get_HashCode() const noexcept
Definition: cNetSocket.h:345
Definition: cNetStream.h:20
HASHCODE_t get_HashCode() const noexcept
Definition: cNetStream.h:71
Definition: cProtocol.h:147
Definition: cProtocol.h:24
Definition: cThread.h:256
ITERATE_t GetSize() const noexcept
Definition: cArray.h:137
Definition: cArrayRef.h:21
bool IsValidIndex(ITERATE_t i) const noexcept
Definition: cArraySort.h:432
Definition: cArraySortRef.h:60
Definition: cThreadArray.h:240
ITERATE_t GetSize() const
Definition: cThreadArray.h:263
UNITTEST2_PREDEF(cQuadtree)
cRefPtr< cNetServerPort > cNetServerPortPtr
Definition: cNetServer.h:49
cRefPtr< cNetServerThread > cNetServerThreadPtr
Definition: cNetServer.h:154
cRefPtr< cNetServerConnection > cNetServerConnectionPtr
Definition: cNetServer.h:104
LONG LSTATUS
AKA error_status_t. FACILITY_WIN32 codes returned from RegCreateKeyEx() etc. Maybe NOT GetLastError()...
Definition: HResult.h:74
INT32 TIMESYSD_t
Time delta. signed milli-Seconds Span. cTimeSys::k_DMAX, cTimeSys::k_INF = MAILSLOT_WAIT_FOREVER.
Definition: cTimeSys.h:28
int ITERATE_t
like size_t but signed
Definition: Index.h:28
WORD RADIX_t
Base for convert of numbers to strings. e.g. 10 base vs 16 base hex numbers.
Definition: StrChar.h:27
UINT_PTR HASHCODE_t
could hold a pointer converted to a number? maybe 64 or 32 bit ? same as size_t.
Definition: GrayCore.h:116
const char *__stdcall StrArg< char >(const char *pszStr) noexcept
Definition: StrArg.h:63
Definition: cProtocol.h:125