OSVR-Core
|
Class handling a run-loop with a registration context and connection. More...
#include <Server.h>
Public Member Functions | |
Server (connection::ConnectionPtr const &conn, boost::optional< std::string > const &host, boost::optional< int > const &port, private_constructor const &) | |
Private server constructor. More... | |
OSVR_SERVER_EXPORT | ~Server () |
Destructor - stops the loop and blocks until it's done. | |
OSVR_SERVER_EXPORT void | update () |
If you aren't using a separate thread for the server, this method will run a single update of the server. More... | |
OSVR_SERVER_EXPORT void | start () |
Launch a thread running the server. More... | |
OSVR_SERVER_EXPORT void | startAndAwaitShutdown () |
Launch a thread running the server, and block until the server shuts down. More... | |
OSVR_SERVER_EXPORT void | awaitShutdown () |
Block until the server shuts down. More... | |
OSVR_SERVER_EXPORT void | stop () |
Signal the server to stop (if it is running), and block until it does so. More... | |
OSVR_SERVER_EXPORT void | signalStop () |
Signal the server to stop (if it is running) but return immediately. More... | |
OSVR_SERVER_EXPORT void | loadPlugin (std::string const &plugin) |
Load plugin by name. More... | |
OSVR_SERVER_EXPORT void | loadAutoPlugins () |
Load all auto-loadable plugins. | |
OSVR_SERVER_EXPORT void | setHardwareDetectOnConnection () |
Adds the behavior that hardware detection should take place on client connection. More... | |
OSVR_SERVER_EXPORT void | instantiateDriver (std::string const &plugin, std::string const &driver, std::string const ¶ms=std::string()) |
Instantiate the named driver with parameters. More... | |
OSVR_SERVER_EXPORT void | triggerHardwareDetect () |
Run all hardware detect callbacks. More... | |
OSVR_SERVER_EXPORT void | registerMainloopMethod (MainloopMethod f) |
Register a method to run during every time through the main loop. More... | |
OSVR_SERVER_EXPORT bool | addRoute (std::string const &routingDirective) |
Register a JSON string as a routing directive. More... | |
OSVR_SERVER_EXPORT bool | addAlias (std::string const &path, std::string const &source, common::AliasPriority priority=common::ALIASPRIORITY_MANUAL) |
Add an alias entry to the tree. More... | |
OSVR_SERVER_EXPORT bool | addString (std::string const &path, std::string const &value) |
Add a string entry to the tree. More... | |
OSVR_SERVER_EXPORT bool | addAliases (Json::Value const &aliases, common::AliasPriority priority=common::ALIASPRIORITY_MANUAL) |
Add alias entries to the tree from JSON. More... | |
OSVR_SERVER_EXPORT void | addExternalDevice (std::string const &path, std::string const &deviceName, std::string const &server, std::string const &descriptor) |
Add an external device entry manually to the tree. More... | |
OSVR_SERVER_EXPORT void | setSleepTime (int microseconds) |
Sets the amount of time (in microseconds) that the server loop will sleep each loop when a client is connected (0 means no sleep) More... | |
Static Public Member Functions | |
static OSVR_SERVER_EXPORT ServerPtr | createLocal () |
Create a server object with a local-only (but still IP-based) connection. More... | |
static OSVR_SERVER_EXPORT ServerPtr | create (connection::ConnectionPtr const &conn) |
Create a server object with a provided connection. More... | |
static OSVR_SERVER_EXPORT ServerPtr | create (connection::ConnectionPtr const &conn, boost::optional< std::string > const &host, boost::optional< int > const &port) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Parameters left unspecified/as boost::none will be filled with default values. More... | |
static OSVR_SERVER_EXPORT ServerPtr | createNonListening (connection::ConnectionPtr const &conn) |
Create a server object with a provided connection with a provided connection that has been asserted to not listen at all to outside processes. More... | |
Class handling a run-loop with a registration context and connection.
osvr::server::Server::Server | ( | connection::ConnectionPtr const & | conn, |
boost::optional< std::string > const & | host, | ||
boost::optional< int > const & | port, | ||
private_constructor const & | |||
) |
Private server constructor.
The last argument is a dummy argument to enforce use of the factory methods.
std::logic_error | if a null connection is passed. |
bool osvr::server::Server::addAlias | ( | std::string const & | path, |
std::string const & | source, | ||
common::AliasPriority | priority = common::ALIASPRIORITY_MANUAL |
||
) |
Add an alias entry to the tree.
If the server is running, this will trigger a re-transmission of the path tree to all clients.
Safe to call from any thread, even when server is running.
bool osvr::server::Server::addAliases | ( | Json::Value const & | aliases, |
common::AliasPriority | priority = common::ALIASPRIORITY_MANUAL |
||
) |
Add alias entries to the tree from JSON.
If the server is running, this will trigger a re-transmission of the path tree to all clients.
Safe to call from any thread, even when server is running.
void osvr::server::Server::addExternalDevice | ( | std::string const & | path, |
std::string const & | deviceName, | ||
std::string const & | server, | ||
std::string const & | descriptor | ||
) |
Add an external device entry manually to the tree.
If the server is running, this will trigger a re-transmission of the path tree to all clients.
Safe to call from any thread, even when server is running.
bool osvr::server::Server::addRoute | ( | std::string const & | routingDirective | ) |
Register a JSON string as a routing directive.
If the server is running, this will trigger a re-transmission of the path tree to all clients.
Safe to call from any thread, even when server is running.
bool osvr::server::Server::addString | ( | std::string const & | path, |
std::string const & | value | ||
) |
Add a string entry to the tree.
If the server is running, this will trigger a re-transmission of the path tree to all clients.
Safe to call from any thread, even when server is running.
void osvr::server::Server::awaitShutdown | ( | ) |
Block until the server shuts down.
Do not call from within the server thread itself, of course.
|
static |
Create a server object with a provided connection.
conn | A non-null connection pointer. Since an osvr::connection::ConnectionPtr is a shared pointer, the server takes shared ownership of the connection passed. |
std::logic_error | if a null connection is passed. |
|
static |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Parameters left unspecified/as boost::none will be filled with default values.
|
static |
Create a server object with a local-only (but still IP-based) connection.
|
static |
Create a server object with a provided connection with a provided connection that has been asserted to not listen at all to outside processes.
void osvr::server::Server::instantiateDriver | ( | std::string const & | plugin, |
std::string const & | driver, | ||
std::string const & | params = std::string() |
||
) |
Instantiate the named driver with parameters.
plugin | The name of a plugin. |
driver | The name of a driver registered by the plugin for creation in this way. |
params | A string containing parameters. Format is between you and the plugin, but JSON is recommended. |
Call only before starting the server or from within server thread.
void osvr::server::Server::loadPlugin | ( | std::string const & | plugin | ) |
Load plugin by name.
Safe to call from any thread, even when server is running.
void osvr::server::Server::registerMainloopMethod | ( | MainloopMethod | f | ) |
Register a method to run during every time through the main loop.
Safe to call from any thread, even when server is running.
void osvr::server::Server::setHardwareDetectOnConnection | ( | ) |
Adds the behavior that hardware detection should take place on client connection.
Safe to call from any thread, even when server is running, though it makes the most sense as a startup option.
void osvr::server::Server::setSleepTime | ( | int | microseconds | ) |
Sets the amount of time (in microseconds) that the server loop will sleep each loop when a client is connected (0 means no sleep)
Call only before starting the server or from within server thread.
void osvr::server::Server::signalStop | ( | ) |
Signal the server to stop (if it is running) but return immediately.
Safe to call from any thread.
void osvr::server::Server::start | ( | ) |
Launch a thread running the server.
std::logic_error | if called after the server has stopped. |
void osvr::server::Server::startAndAwaitShutdown | ( | ) |
Launch a thread running the server, and block until the server shuts down.
std::logic_error | if called after the server has stopped. |
void osvr::server::Server::stop | ( | ) |
Signal the server to stop (if it is running), and block until it does so.
Safe to call from any non-server thread, do not call from within the server thread itself, of course.
void osvr::server::Server::triggerHardwareDetect | ( | ) |
Run all hardware detect callbacks.
Safe to call from any thread, even when server is running.
void osvr::server::Server::update | ( | ) |
If you aren't using a separate thread for the server, this method will run a single update of the server.