# Server.hpp
This File On Github
Ask A Question
API: latest
module: oatpp
#include "oatpp/network/Server.hpp"
# Server
Server calls oatpp::network::ConnectionProvider::get in the loop and passes obtained Connection to oatpp::network::ConnectionHandler.
namespace oatpp { namespace network {
class Server : public base::Countable {}
}}
# Fields
Type | Name | Summary |
---|---|---|
const v_int32 | STATUS_CREATED | Status constant. |
const v_int32 | STATUS_STARTING | Status constant. |
const v_int32 | STATUS_RUNNING | Status constant. |
const v_int32 | STATUS_STOPPING | Status constant. |
const v_int32 | STATUS_DONE | Status constant. |
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | Server | Constructor. |
std::shared_ptr<Server> | createShared | Create shared Server. |
void | run | Multiple implementations:
|
void | stop | Break server loop. |
v_int32 | getStatus | Get server status. |
# Server::STATUS_CREATED
Status constant.
static const v_int32 STATUS_CREATED
# Server::STATUS_STARTING
Status constant.
static const v_int32 STATUS_STARTING
# Server::STATUS_RUNNING
Status constant.
static const v_int32 STATUS_RUNNING
# Server::STATUS_STOPPING
Status constant.
static const v_int32 STATUS_STOPPING
# Server::STATUS_DONE
Status constant.
static const v_int32 STATUS_DONE
# Server::Server
Constructor.
- @param connectionProvider - oatpp::network::ConnectionProvider.
- @param connectionHandler - oatpp::network::ConnectionHandler.
Server(const std::shared_ptr<ConnectionProvider>& connectionProvider,
const std::shared_ptr<ConnectionHandler>& connectionHandler)
# Server::createShared
Create shared Server.
- @param connectionProvider - oatpp::network::ConnectionProvider.
- @param connectionHandler - oatpp::network::ConnectionHandler.
- @return -
std::shared_ptr
to Server.
static std::shared_ptr<Server> createShared(const std::shared_ptr<ServerConnectionProvider>& connectionProvider,
const std::shared_ptr<ConnectionHandler>& connectionHandler)
# Server::run
- Call oatpp::network::ConnectionProvider::getConnection in the loop and passes obtained Connection to oatpp::network::ConnectionHandler.
- @param conditional - Function that is called every mainloop iteration to check if the server should continue to run
Return true to let the server continue, false to shut it down.
void run(std::function<bool()> conditional = nullptr)
- @param conditional - Function that is called every mainloop iteration to check if the server should continue to run
- Call oatpp::network::ConnectionProvider::getConnection in the loop and passes obtained Connection to oatpp::network::ConnectionHandler.
- @param startAsNewThread - Start the server blocking (thread of callee) or non-blocking (own thread) deprecated Deprecated since 1.3.0, will be removed in the next release. The new repository https://github.com/oatpp/oatpp-threaded-starter shows many configurations how to run Oat++ in its own thread. From simple No-Stop to Stop-Simple and ending in Oat++ completely isolated in its own thread-scope. We recommend the Stop-Simple for most applications! You can find it here: https://github.com/oatpp/oatpp-threaded-starter/blob/master/src/App_StopSimple.cpp The other examples are non trivial and highly specialized on specific environments or requirements. Please read the comments carefully and think about the consequences twice. If someone wants to use them please get back to us in an issue in the new repository and we can assist you with them. Again: These examples introduce special conditions and requirements for your code!
void run(bool startAsNewThread)
# Server::stop
Break server loop. Note: thread can still be blocked on the Server::run() call as it may be waiting for ConnectionProvider to provide connection.
void stop()
# Server::getStatus
Get server status.
- @return - one of:
v_int32 getStatus()