From ee131921a0140bc756db11e588e409ae2b524751 Mon Sep 17 00:00:00 2001 From: andrey Date: Thu, 12 Aug 2021 20:22:43 +0300 Subject: [PATCH] add PIByteArray operator <, fix picloud --- libs/main/core/pibytearray.h | 11 +++++++++++ utils/cloud_dispatcher/dispatcherserver.cpp | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/libs/main/core/pibytearray.h b/libs/main/core/pibytearray.h index b872521b..78a97975 100644 --- a/libs/main/core/pibytearray.h +++ b/libs/main/core/pibytearray.h @@ -198,6 +198,17 @@ inline bool operator <(const PIByteArray & v0, const PIByteArray & v1) { return v0.size() < v1.size(); } +//! \relatesalso PIByteArray @brief Byte arrays compare operator +inline bool operator >(const PIByteArray & v0, const PIByteArray & v1) { + if (v0.size() == v1.size()) { + for (uint i = 0; i < v0.size(); ++i) + if (v0[i] != v1[i]) + return v0[i] > v1[i]; + return false; + } + return v0.size() > v1.size(); +} + //! \relatesalso PIByteArray @brief Byte arrays compare operator inline bool operator ==(PIByteArray & f, PIByteArray & s) { if (f.size_s() != s.size_s()) diff --git a/utils/cloud_dispatcher/dispatcherserver.cpp b/utils/cloud_dispatcher/dispatcherserver.cpp index 21cdf9e2..6ebc0094 100644 --- a/utils/cloud_dispatcher/dispatcherserver.cpp +++ b/utils/cloud_dispatcher/dispatcherserver.cpp @@ -60,6 +60,8 @@ void DispatcherServer::cleanClients() { } for (auto c: rmrf_clients) { clients.removeAll(c); + index_c_servers.remove(c); + index_c_clients.remove(c); rm_clients.removeAll(c); } map_mutex.unlock(); @@ -209,6 +211,7 @@ void DispatcherServer::newConnection(PIEthernet *cl) { CloudServer * cs = c_servers.value(sname, nullptr); if (cs) { rm_clients << c; + piCoutObj << "dublicate Server ->" << sname.toHex(); } else { piCoutObj << "add new Server ->" << sname.toHex(); CloudServer * cs = new CloudServer(c, sname); @@ -228,6 +231,7 @@ void DispatcherServer::newConnection(PIEthernet *cl) { c->authorise(true); } else { rm_clients << c; + piCoutObj << "Client can't connect to Server ->" << sname.toHex(); } map_mutex.unlock(); });