diff --git a/lib/inc/drogon/HttpAppFramework.h b/lib/inc/drogon/HttpAppFramework.h index 5be17c48..88911196 100644 --- a/lib/inc/drogon/HttpAppFramework.h +++ b/lib/inc/drogon/HttpAppFramework.h @@ -1521,6 +1521,10 @@ class DROGON_EXPORT HttpAppFramework : public trantor::NonCopyable virtual HttpAppFramework &enableCompressedRequest(bool enable = true) = 0; virtual bool isCompressedRequestEnabled() const = 0; + /* + * @brief get the number of active connections. + */ + virtual int64_t getConnectionCount() const = 0; private: virtual void registerHttpController( diff --git a/lib/src/HttpAppFrameworkImpl.h b/lib/src/HttpAppFrameworkImpl.h index 8d62cc19..4f689eb5 100644 --- a/lib/src/HttpAppFrameworkImpl.h +++ b/lib/src/HttpAppFrameworkImpl.h @@ -606,6 +606,11 @@ class HttpAppFrameworkImpl final : public HttpAppFramework const std::string &ext, const std::string &mime) override; + int64_t getConnectionCount() const override + { + return connectionNum_.load(std::memory_order_relaxed); + } + private: void registerHttpController(const std::string &pathPattern, const internal::HttpBinderBasePtr &binder,