EHS
NetEnd.h
Go to the documentation of this file.
1#pragma once
2
3#include "NetUtils.h"
4#include "NetFrag.h"
5
6#include "ehs/Str.h"
7#include "ehs/Vector.h"
8#include "ehs/Serializer.h"
10
11namespace ehs
12{
13 class NetServerCh;
14
15 class NetEnd
16 {
17 private:
18 friend class NetServerCh;
19
20 NetServerCh* owner;
21 UInt_64 id;
22 Str_8 name;
23 NetStatus status;
24 Char_8 token[64];
25 UInt_64 nextSendId;
27 UInt_64 nextRecvId;
28 Vector<NetFrag> received;
29 Endpoint endpoint;
30 float deltaDuration;
31 float deltaRate;
32 float timeout;
33 float lastPing;
34 float oldLatency;
35 float latency;
36 UInt_64 queueSlot;
37
38 public:
39 NetEnd();
40
41 NetEnd(Str_8 id, Endpoint endpoint);
42
43 NetEnd(Endpoint endpoint);
44
45 NetEnd(NetEnd &&end) noexcept;
46
47 NetEnd(const NetEnd &end);
48
49 NetEnd &operator=(NetEnd &&end) noexcept;
50
51 NetEnd &operator=(const NetEnd &end);
52
53 UInt_64 GetId() const;
54
55 Str_8 GetName() const;
56
57 NetStatus GetStatus() const;
58
59 UInt_64 GetNextSendId() const;
60
68 void Send(bool deltaLocked, UInt_64 encId, bool ensure, UInt_64 sysId, UInt_64 opId, const Serializer<UInt_64>& payload);
69
77 void Send(bool deltaLocked, const Str_8 &encName, bool ensure, const Str_8& sysName, const Str_8& opName, const Serializer<UInt_64>& payload);
78
79 UInt_64 GetNextRecvId() const;
80
81 Endpoint GetEndpoint() const;
82
83 void SetDeltaRate(float newDeltaRate);
84
85 float GetDeltaRate() const;
86
87 float GetTimeout() const;
88
89 float GetLastPing() const;
90
91 void SendLatency();
92
93 float GetLatency() const;
94
95 UInt_64 GetQueueSlot() const;
96
97 private:
98 void Poll(float delta);
99
100 void SetStatus(NetStatus newStatus);
101
102 void RemoveInsurance(UInt_64 msgId, UInt_64 fragment);
103
104 void AddReceived(const Header& header, const Serializer<>& payload);
105
106 Vector<NetFrag>* GetReceived();
107
108 void Ping(float delta);
109
110 void SetLatency(float newLatency);
111
112 void SetQueueSlot(UInt_64 slot);
113
114 NetFrag FragmentData(const Header& header, const Serializer<>& data);
115
116 void Send(const Header& header, const Serializer<>& payload);
117
118 bool SortingNeeded() const;
119
120 void SortReceived();
121 };
122}
Definition: NetEnd.h:16
void SetDeltaRate(float newDeltaRate)
Definition: NetEnd.cpp:344
UInt_64 GetQueueSlot() const
Definition: NetEnd.cpp:234
float GetLastPing() const
Definition: NetEnd.cpp:224
Str_8 GetName() const
Definition: NetEnd.cpp:131
UInt_64 GetNextSendId() const
Definition: NetEnd.cpp:141
float GetDeltaRate() const
Definition: NetEnd.cpp:214
void Send(bool deltaLocked, const Str_8 &encName, bool ensure, const Str_8 &sysName, const Str_8 &opName, const Serializer< UInt_64 > &payload)
UInt_64 GetId() const
Definition: NetEnd.cpp:126
void SendLatency()
Definition: NetEnd.cpp:359
NetEnd & operator=(NetEnd &&end) noexcept
Definition: NetEnd.cpp:60
Endpoint GetEndpoint() const
Definition: NetEnd.cpp:209
float GetLatency() const
Definition: NetEnd.cpp:229
NetStatus GetStatus() const
Definition: NetEnd.cpp:136
void Send(bool deltaLocked, UInt_64 encId, bool ensure, UInt_64 sysId, UInt_64 opId, const Serializer< UInt_64 > &payload)
Definition: NetEnd.cpp:146
UInt_64 GetNextRecvId() const
Definition: NetEnd.cpp:204
float GetTimeout() const
Definition: NetEnd.cpp:219
NetEnd()
Definition: NetEnd.cpp:9
Definition: NetFrag.h:10
Definition: NetServerCh.h:10
Definition: Vector.h:18
Definition: Anchor.h:6
NetStatus
Definition: NetUtils.h:8
char Char_8
Definition: Types.h:40
Definition: Socket.h:48
Definition: NetUtils.h:22