EHS
Loading...
Searching...
No Matches
NetServerCh.h
Go to the documentation of this file.
1#pragma once
2
3#include "NetChannel.h"
4
5namespace ehs
6{
7 class NetEnd;
8
9 class NetServerCh : public NetChannel
10 {
11 private:
12 friend class EHC;
13
14 Vector<NetEnd *> endpoints;
15 UInt_64 maxEndpoints;
16
17 public:
18 ~NetServerCh() override;
19
21
22 NetServerCh(Str_8 name, const Version &version, UInt_64 maxEndpoints);
23
24 NetServerCh(NetServerCh &&server) noexcept;
25
26 NetServerCh(const NetServerCh &server);
27
28 NetServerCh &operator=(NetServerCh &&server) noexcept;
29
30 NetServerCh &operator=(const NetServerCh &server);
31
32 virtual bool OnEndpointConnect(NetEnd *endpoint, Serializer<UInt_64> payload);
33
35
36 virtual void OnEndpointDisconnect(NetEnd *endpoint, Serializer<UInt_64> payload);
37
38 virtual void OnEndpointTimeout(NetEnd *endpoint);
39
40 virtual void OnEndpointActive(NetEnd *endpoint);
41
43
44 void Broadcast(NetStatus endStatus, bool deltaLocked, UInt_64 encHashId,
45 bool ensure, UInt_64 sysHashId, UInt_64 opHashId,
46 const Serializer<UInt_64> &payload);
47
48 void Broadcast(NetStatus endStatus, bool deltaLocked, const Str_8 &encId,
49 bool ensure, const Str_8 &sysId, const Str_8 &opId,
50 const Serializer<UInt_64> &payload);
51
52 bool HasEndpoint(NetStatus endStatus, const Char_8 token[64]) const;
53
54 bool HasEndpoint(NetStatus endStatus, UInt_64 hashId) const;
55
56 bool HasEndpoint(NetStatus endStatus, const Str_8 &id) const;
57
58 bool HasEndpoint(const Char_8 token[64]) const;
59
60 bool HasEndpoint(UInt_64 hashId) const;
61
62 bool HasEndpoint(const Str_8 &id) const;
63
64 bool HasEndpoint(const Endpoint &endpoint) const;
65
66 NetEnd *GetEndpoint(NetStatus endStatus, const Char_8 token[64]) const;
67
68 NetEnd *GetEndpoint(NetStatus endStatus, UInt_64 hashId) const;
69
70 NetEnd *GetEndpoint(NetStatus endStatus, const Str_8 &id) const;
71
72 NetEnd *GetEndpoint(const Char_8 token[64]) const;
73
74 NetEnd *GetEndpoint(UInt_64 hashId) const;
75
76 NetEnd *GetEndpoint(const Str_8 &id) const;
77
78 NetEnd *GetEndpoint(const Endpoint &endpoint) const;
79
81
82 UInt_64 GetEndpointsCount(NetStatus endStatus);
83
84 UInt_64 GetMaxEndpoints() const;
85
86 private:
87 void Process(const float &delta, const Endpoint &endpoint, const Header &header, Serializer<UInt_64> &payload) override;
88
89 void GenerateToken(Char_8 in[64]);
90
91 void UpdateQueue(UInt_64 active);
92
93 void UpdateQueue();
94
95 bool RemoveEndpoint(const Char_8 token[64]);
96
97 bool RemoveEndpoint(const Endpoint &endpoint);
98
99 bool RemoveEndpoint(const NetEnd* end);
100
101 void Poll(const float &delta) override;
102
103 void Shutdown();
104 };
105}
Definition Array.h:16
NetChannel()
Definition NetChannel.cpp:25
Definition NetEnd.h:16
NetServerCh & operator=(NetServerCh &&server) noexcept
Definition NetServerCh.cpp:36
UInt_64 GetEndpointsCount(NetStatus endStatus)
Definition NetServerCh.cpp:265
NetServerCh()
Definition NetServerCh.cpp:14
UInt_64 GetMaxEndpoints() const
Definition NetServerCh.cpp:276
Array< NetEnd * > GetEndpoints(NetStatus endStatus)
Definition NetServerCh.cpp:251
virtual Serializer< UInt_64 > OnEndpointAccepted(NetEnd *endpoint)
Definition NetServerCh.cpp:76
bool HasEndpoint(NetStatus endStatus, const Char_8 token[64]) const
Definition NetServerCh.cpp:121
virtual void OnEndpointDisconnect(NetEnd *endpoint, Serializer< UInt_64 > payload)
Definition NetServerCh.cpp:81
friend class EHC
Definition NetServerCh.h:12
~NetServerCh() override
Definition NetServerCh.cpp:9
virtual bool OnEndpointConnect(NetEnd *endpoint, Serializer< UInt_64 > payload)
Definition NetServerCh.cpp:71
NetEnd * GetEndpoint(NetStatus endStatus, const Char_8 token[64]) const
Definition NetServerCh.cpp:186
virtual Serializer< UInt_64 > OnShutdown()
Definition NetServerCh.cpp:93
void Broadcast(NetStatus endStatus, bool deltaLocked, UInt_64 encHashId, bool ensure, UInt_64 sysHashId, UInt_64 opHashId, const Serializer< UInt_64 > &payload)
Definition NetServerCh.cpp:103
virtual void OnEndpointActive(NetEnd *endpoint)
Definition NetServerCh.cpp:89
virtual void OnEndpointTimeout(NetEnd *endpoint)
Definition NetServerCh.cpp:85
Definition Serializer.h:25
Definition Vector.h:18
A helper class for storing version major, minor and patch.
Definition Version.h:9
Definition Anchor.h:6
NetStatus
Definition NetUtils.h:8
char Char_8
Definition Types.h:40
Str< Char_8, UInt_64 > Str_8
Definition Str.h:1953
Definition Socket.h:48
Definition NetUtils.h:22