42 connection::Connection::createLocalConnection());
43 ServerPtr ret(std::make_shared<Server>(conn, boost::none, boost::none,
44 private_constructor{}));
50 ServerPtr ret(std::make_shared<Server>(conn, boost::none, boost::none,
51 private_constructor{}));
57 boost::optional<std::string>
const &host,
58 boost::optional<int>
const &port) {
60 std::make_shared<Server>(conn, host, port, private_constructor{}));
67 conn, boost::optional<std::string>{},
69 private_constructor{}));
86 m_impl->loadPlugin(plugin);
92 m_impl->setHardwareDetectOnConnection();
96 std::string
const &driver,
97 std::string
const ¶ms) {
98 m_impl->instantiateDriver(plugin, driver, params);
104 m_impl->registerMainloopMethod(f);
108 return m_impl->addRoute(routingDirective);
112 common::AliasPriority priority) {
113 return m_impl->addAlias(path, source, priority);
117 return m_impl->addString(path, value);
121 common::AliasPriority priority) {
122 return m_impl->addAliases(aliases, priority);
126 std::string
const &deviceName,
127 std::string
const &server,
128 std::string
const &descriptor) {
129 m_impl->addExternalDevice(path, deviceName, server, descriptor);
133 m_impl->setSleepTime(microseconds);
136 int Server::getSleepTime()
const {
return m_impl->getSleepTime(); }
140 boost::optional<std::string>
const &host,
141 boost::optional<int>
const &port,
142 private_constructor
const &)
OSVR_SERVER_EXPORT void startAndAwaitShutdown()
Launch a thread running the server, and block until the server shuts down.
Header defining some special values that may be passed to some functions that request a port number t...
OSVR_SERVER_EXPORT bool addAliases(Json::Value const &aliases, common::AliasPriority priority=common::ALIASPRIORITY_MANUAL)
Add alias entries to the tree from JSON.
OSVR_SERVER_EXPORT void start()
Launch a thread running the server.
OSVR_SERVER_EXPORT void triggerHardwareDetect()
Run all hardware detect callbacks.
OSVR_SERVER_EXPORT bool addString(std::string const &path, std::string const &value)
Add a string entry to the tree.
std::function< void()> MainloopMethod
A function that can be registered by the server app to run in each mainloop iteration.
shared_ptr< Connection > ConnectionPtr
How one must hold a Connection.
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.
OSVR_SERVER_EXPORT void loadPlugin(std::string const &plugin)
Load plugin by name.
OSVR_SERVER_EXPORT void registerMainloopMethod(MainloopMethod f)
Register a method to run during every time through the main loop.
OSVR_SERVER_EXPORT void stop()
Signal the server to stop (if it is running), and block until it does so.
OSVR_SERVER_EXPORT ~Server()
Destructor - stops the loop and blocks until it's done.
OSVR_SERVER_EXPORT void setHardwareDetectOnConnection()
Adds the behavior that hardware detection should take place on client connection. ...
OSVR_SERVER_EXPORT void awaitShutdown()
Block until the server shuts down.
OSVR_SERVER_EXPORT bool addRoute(std::string const &routingDirective)
Register a JSON string as a routing directive.
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.
Header declaring osvr::server::Server.
static OSVR_SERVER_EXPORT ServerPtr create(connection::ConnectionPtr const &conn)
Create a server object with a provided connection.
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 t...
Private implementation class for Server.
Server(connection::ConnectionPtr const &conn, boost::optional< std::string > const &host, boost::optional< int > const &port, private_constructor const &)
Private server constructor.
shared_ptr< Server > ServerPtr
How one should hold a Server.
OSVR_SERVER_EXPORT void signalStop()
Signal the server to stop (if it is running) but return immediately.
OSVR_SERVER_EXPORT void loadAutoPlugins()
Load all auto-loadable plugins.
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 ser...
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 ...
static OSVR_SERVER_EXPORT ServerPtr createLocal()
Create a server object with a local-only (but still IP-based) connection.
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.