$darkmode
oak::Server Class Reference

#include <server.hpp>

Public Member Functions

 Server (const std::string &addr, int port)
 
 ~Server ()
 
void set_threads (int n)
 
void set_address (const std::string &addr)
 
const std::string & address () const
 
void set_port (int port)
 
int port () const
 
bool is_listening () const
 
void listen ()
 
fable::Json endpoints_to_json (const std::vector< std::string > &endpoints) const
 
void stop ()
 
std::vector< std::string > endpoints () const
 

Protected Member Functions

void add_handler (const std::string &key, cloe::Handler h)
 

Protected Attributes

friend StaticRegistrar
 
friend LockedRegistrar
 
friend BufferRegistrar
 

Detailed Description

A Server accepts and serves endpoints for Handlers.

This is a convenience wrapper around ServerImpl.

Constructor & Destructor Documentation

◆ ~Server()

oak::Server::~Server ( )

When a Server goes out of scope, it will stop listening for you if you haven't done so already.

Here is the call graph for this function:

Member Function Documentation

◆ add_handler()

void oak::Server::add_handler ( const std::string &  key,
cloe::Handler  h 
)
protected

Add a handler with the route muxer in the internal handler routine.

◆ endpoints()

std::vector< std::string > oak::Server::endpoints ( ) const

Return a list of all registered endpoints.

Here is the caller graph for this function:

◆ endpoints_to_json()

fable::Json oak::Server::endpoints_to_json ( const std::vector< std::string > &  endpoints) const

Return endpoint data in json format.

◆ is_listening()

bool oak::Server::is_listening ( ) const
inline

Returns whether the server has started and is currently listening.

Here is the caller graph for this function:

◆ listen()

void oak::Server::listen ( )

Start the server.

Here is the caller graph for this function:

◆ set_address()

void oak::Server::set_address ( const std::string &  addr)
inline

Set the address on which the server will listen.

  • Use 127.0.0.1 to only allow local connections.
  • Use 0.0.0.0 to listen on all interfaces. This will allow clients from the entire network to access this service, if the system firewall allows it.
Here is the caller graph for this function:

◆ set_port()

void oak::Server::set_port ( int  port)
inline

Set the port on which to listen.

Here is the caller graph for this function:

◆ set_threads()

void oak::Server::set_threads ( int  n)
inline

Set the number of threads used for listening to connections. This is the number of requests that can be handled simultaneously.

NOTE: This doesn't do anything at the moment; a new thread is created for each connection.

Here is the caller graph for this function:

◆ stop()

void oak::Server::stop ( )

Stop the server.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: