104 public std::enable_shared_from_this<UNetReceiver>
107 UNetReceiver( std::unique_ptr<UNetReceiveTransport>&& transport,
const std::shared_ptr<SMInterface>& smi
108 ,
bool nocheckConnection =
false
109 ,
const std::string& prefix =
"unet" );
115 inline std::string getName()
const noexcept
121 void setLockUpdate(
bool st )
noexcept;
122 bool isLockUpdate()
const noexcept;
124 void resetTimeout()
noexcept;
126 bool isInitOK()
const noexcept;
127 bool isRecvOK()
const noexcept;
128 size_t getLostPacketsNum()
const noexcept;
130 void setReceiveTimeout( timeout_t msec )
noexcept;
131 void setUpdatePause( timeout_t msec )
noexcept;
132 void setLostTimeout( timeout_t msec )
noexcept;
133 void setPrepareTime( timeout_t msec )
noexcept;
134 void setCheckConnectionPause( timeout_t msec )
noexcept;
135 void setMaxDifferens(
unsigned long set )
noexcept;
136 void setEvrunTimeout(timeout_t msec )
noexcept;
137 void setInitPause( timeout_t msec )
noexcept;
138 void setBufferSize(
size_t sz )
noexcept;
139 void setMaxReceiveAtTime(
size_t sz )
noexcept;
140 void setIgnoreCRC(
bool set )
noexcept;
146 void forceUpdate()
noexcept;
148 inline std::string getTransportID()
const noexcept
150 return transport->ID();
166 typedef sigc::slot<void, const std::shared_ptr<UNetReceiver>&,
Event> EventSlot;
167 void connectEvent( EventSlot sl )
noexcept;
170 inline std::shared_ptr<DebugStream> getLog() noexcept
175 std::string getShortInfo() const noexcept;
179 const
std::shared_ptr<SMInterface> shm;
189 ReceiveRetCode receive() noexcept;
190 void update() noexcept;
191 void callback( ev::io& watcher,
int revents ) noexcept;
192 void readEvent( ev::io& watcher ) noexcept;
193 void updateEvent( ev::periodic& watcher,
int revents ) noexcept;
194 void checkConnectionEvent( ev::periodic& watcher,
int revents ) noexcept;
195 void statisticsEvent( ev::periodic& watcher,
int revents ) noexcept;
196 void onForceUpdate( ev::async& watcher,
int revents ) noexcept;
197 void initEvent( ev::timer& watcher,
int revents ) noexcept;
198 virtual
void evprepare( const ev::loop_ref& eloop ) noexcept override;
199 virtual
void evfinish(const ev::loop_ref& eloop ) noexcept override;
200 virtual
std::
string wname() const noexcept
override
205 void initIterators() noexcept;
206 bool createConnection(
bool throwEx = false );
207 bool checkConnection();
208 size_t rnext(
size_t num );
213 timeout_t updatepause = { 100 };
215 std::unique_ptr<UNetReceiveTransport> transport;
219 ev::periodic evCheckConnection;
220 ev::periodic evStatistic;
221 ev::periodic evUpdate;
222 ev::timer evInitPause;
223 ev::async evForceUpdate;
226 size_t recvCount = { 0 };
227 size_t upCount = { 0 };
228 std::chrono::steady_clock::time_point t_start;
229 std::chrono::steady_clock::time_point t_end;
230 std::chrono::steady_clock::time_point t_stats;
235 float recvPerSec = {0};
236 float upPerSec = {0};
237 size_t upProcessingTime_microsec = {0};
238 size_t recvProcessingTime_microsec = {0};
244 static CommonEventLoop loop;
246 double checkConnectionTime = { 10.0 };
247 std::mutex checkConnMutex;
249 PassiveTimer ptRecvTimeout;
250 PassiveTimer ptPrepare;
251 timeout_t recvTimeout = { 5000 };
252 timeout_t prepareTime = { 2000 };
253 timeout_t evrunTimeout = { 15000 };
254 timeout_t lostTimeout = { 200 };
255 size_t maxReceiveCount = { 5 };
257 double initPause = { 5.0 };
258 std::atomic_bool initOK = {
false };
260 PassiveTimer ptLostTimeout;
261 size_t lostPackets = { 0 };
264 IOController::IOStateList::iterator itRespond;
265 bool respondInvert = {
false };
267 IOController::IOStateList::iterator itLostPackets;
271 IOController::IOStateList::iterator itMode;
274 std::atomic_bool activated = {
false };
276 size_t cbufSize = { 100 };
277 std::vector<UniSetUDP::UDPMessage> cbuf;
280 UniSetUDP::UDPMessage* pack;
285 size_t maxDifferens = { 20 };
287 std::atomic_bool lockUpdate = {
false };
296 IOController::IOStateList::iterator ioit;
301 typedef std::vector<CacheItem> CacheVec;
308 CacheInfo(): crc(0) {}
312 typedef std::unordered_map<long, CacheInfo> CacheMap;
313 CacheMap d_icache_map;
314 CacheMap a_icache_map;
316 bool ignoreCRC = {
false };
320 CacheInfo* getDCache( UniSetUDP::UDPMessage* upack )
noexcept;
321 CacheInfo* getACache( UniSetUDP::UDPMessage* pack )
noexcept;