From 74bb85efe974c8ea61cb33adb76b2c99d10ad517 Mon Sep 17 00:00:00 2001 From: flagarde Date: Thu, 25 Nov 2021 00:28:25 +0800 Subject: [PATCH] Add getters (#327) * Add getters for IXSocketServer class * Add getters for IXHttpServer class * Add getters for IXWebSocketServer class --- ixwebsocket/IXHttpServer.cpp | 6 ++++++ ixwebsocket/IXHttpServer.h | 1 + ixwebsocket/IXSocketServer.cpp | 25 +++++++++++++++++++++++++ ixwebsocket/IXSocketServer.h | 5 +++++ ixwebsocket/IXWebSocketServer.cpp | 15 +++++++++++++++ ixwebsocket/IXWebSocketServer.h | 3 +++ 6 files changed, 55 insertions(+) diff --git a/ixwebsocket/IXHttpServer.cpp b/ixwebsocket/IXHttpServer.cpp index 070d6fee..563dca91 100644 --- a/ixwebsocket/IXHttpServer.cpp +++ b/ixwebsocket/IXHttpServer.cpp @@ -226,4 +226,10 @@ namespace ix 200, "OK", HttpErrorCode::Ok, headers, std::string("OK")); }); } + + int HttpServer::getTimeoutSecs() + { + return _timeoutSecs; + } + } // namespace ix diff --git a/ixwebsocket/IXHttpServer.h b/ixwebsocket/IXHttpServer.h index 31cd77fb..7de67631 100644 --- a/ixwebsocket/IXHttpServer.h +++ b/ixwebsocket/IXHttpServer.h @@ -40,6 +40,7 @@ namespace ix void makeDebugServer(); + int getTimeoutSecs(); private: // Member variables OnConnectionCallback _onConnectionCallback; diff --git a/ixwebsocket/IXSocketServer.cpp b/ixwebsocket/IXSocketServer.cpp index a242b67d..ed04bb0c 100644 --- a/ixwebsocket/IXSocketServer.cpp +++ b/ixwebsocket/IXSocketServer.cpp @@ -461,4 +461,29 @@ namespace ix // so wake up the thread responsible for that _conditionVariableGC.notify_one(); } + + int SocketServer::getPort() + { + return _port; + } + + std::string SocketServer::getHost() + { + return _host; + } + + int SocketServer::getBacklog() + { + return _backlog; + } + + std::size_t SocketServer::getMaxConnections() + { + return _maxConnections; + } + + int SocketServer::getAddressFamily() + { + return _addressFamily; + } } // namespace ix diff --git a/ixwebsocket/IXSocketServer.h b/ixwebsocket/IXSocketServer.h index a049e24c..fe0f7e28 100644 --- a/ixwebsocket/IXSocketServer.h +++ b/ixwebsocket/IXSocketServer.h @@ -60,6 +60,11 @@ namespace ix void setTLSOptions(const SocketTLSOptions& socketTLSOptions); + int getPort(); + std::string getHost(); + int getBacklog(); + std::size_t getMaxConnections(); + int getAddressFamily(); protected: // Logging void logError(const std::string& str); diff --git a/ixwebsocket/IXWebSocketServer.cpp b/ixwebsocket/IXWebSocketServer.cpp index 8a18f9d0..64830a5f 100644 --- a/ixwebsocket/IXWebSocketServer.cpp +++ b/ixwebsocket/IXWebSocketServer.cpp @@ -211,4 +211,19 @@ namespace ix start(); return true; } + + int WebSocketServer::getHandshakeTimeoutSecs() + { + return _handshakeTimeoutSecs; + } + + bool WebSocketServer::isPongEnabled() + { + return _enablePong; + } + + bool WebSocketServer::isPerMessageDeflateEnabled() + { + return _enablePerMessageDeflate; + } } // namespace ix diff --git a/ixwebsocket/IXWebSocketServer.h b/ixwebsocket/IXWebSocketServer.h index fab7c0e4..6cae6331 100644 --- a/ixwebsocket/IXWebSocketServer.h +++ b/ixwebsocket/IXWebSocketServer.h @@ -52,6 +52,9 @@ namespace ix const static int kDefaultHandShakeTimeoutSecs; + int getHandshakeTimeoutSecs(); + bool isPongEnabled(); + bool isPerMessageDeflateEnabled(); private: // Member variables int _handshakeTimeoutSecs;