diff --git a/src/Network/UdpServer.h b/src/Network/UdpServer.h index a6701c0d..c4f27258 100644 --- a/src/Network/UdpServer.h +++ b/src/Network/UdpServer.h @@ -30,10 +30,10 @@ class UdpServer : public Server { fill(' '); } PeerIdType(size_t len, char fillChar) { - if (len > size()) { - len = size(); - } - fill(fillChar); + //if (len > size()) { + // len = size(); + //} + //fill(fillChar); } bool operator==(const PeerIdType &that) const { return (as(0) == that.as(0)) && (as(8) == that.as(8)) && (as(16) == that.as(16)); @@ -45,8 +45,15 @@ class UdpServer : public Server { return *(reinterpret_cast(data() + offset)); } }; + + struct PeerIdHash { + size_t operator()(const PeerIdType& v) const noexcept { return std::hash {}(std::string_view(v.data(), v.size())); } +}; + using SessionMapType = std::unordered_map; + #else using PeerIdType = std::string; + using SessionMapType = std::unordered_map; #endif using Ptr = std::shared_ptr; @@ -105,14 +112,6 @@ class UdpServer : public Server { virtual void cloneFrom(const UdpServer &that); private: -#if __cplusplus >= 201703L - struct PeerIdHash { - size_t operator()(const PeerIdType &v) const noexcept { return std::hash {}(std::string_view(v.data(), v.size())); } - }; - using SessionMapType = std::unordered_map; -#else - using SessionMapType = std::unordered_map; -#endif /** * @brief 开始udp server * @param port 本机端口,0则随机