| 65 | return ret; |
| 66 | } |
| 67 | ServerImpl::ServerImpl(connection::ConnectionPtr const &conn) |
| 68 | : m_conn(conn), m_ctx(make_shared<pluginhost::RegistrationContext>()), |
| 69 | m_systemComponent(nullptr), m_running(false), m_sleepTime(0) { |
| 70 | if (!m_conn) { |
| 71 | throw std::logic_error( |
| 72 | "Can't pass a null ConnectionPtr into Server constructor!"); |
| 73 | } |
| 74 | osvr::connection::Connection::storeConnection(*m_ctx, m_conn); |
| 75 | |
| 76 | // Get the underlying VRPN connection, and make sure it's OK. |
| 77 | auto vrpnConn = getVRPNConnection(m_conn); |
| 78 | |
| 79 | if (!(vrpnConn->doing_okay())) { |
| 80 | throw ServerCreationFailure(); |
| 81 | } |
| 82 | |
| 83 | // Set up system device/system component |
| 84 | m_systemDevice = common::createServerDevice( |
| 85 | common::SystemComponent::deviceName(), vrpnConn); |
| 86 | |
| 87 | m_systemComponent = |
| 88 | m_systemDevice->addComponent(common::SystemComponent::create()); |
| 89 | m_systemComponent->registerClientRouteUpdateHandler( |
| 90 | &ServerImpl::m_handleUpdatedRoute, this); |
| 91 | |
| 92 | // Things to do when we get a new incoming connection |
| 93 | // No longer doing hardware detect unconditionally here - see triggerHardwareDetect() |
| 94 | m_commonComponent = |
| 95 | m_systemDevice->addComponent(common::CommonComponent::create()); |
| 96 | m_commonComponent->registerPingHandler([&] { m_sendTree(); }); |
| 97 | |
| 98 | // Set up the default display descriptor. |
| 99 | m_tree.getNodeByPath("/display").value() = |
| 100 | common::elements::StringElement(util::makeString(display_json)); |
| 101 | // Deal with updated device descriptors. |
| 102 | m_conn->registerDescriptorHandler([&] { m_handleDeviceDescriptors(); }); |
| 103 | } |
| 104 | |
| 105 | ServerImpl::~ServerImpl() { stop(); } |
| 106 |
nothing calls this directly
no test coverage detected