40 using osvr::connection::DeviceTokenPtr;
48 using osvr::util::GuardPtr;
51 OSVR_DeviceTokenObject::createAsyncDevice(DeviceInitObject &init) {
53 ret->m_sharedInit(init);
60 ret->m_sharedInit(init);
67 DeviceInitObject init(conn);
70 ret->m_sharedInit(init);
74 OSVR_DeviceTokenObject::OSVR_DeviceTokenObject(std::string
const &name)
85 m_sendData(tv, type, bytestream, len);
89 const char *bytestream,
size_t len) {
90 m_sendData(timestamp, type, bytestream, len);
93 GuardPtr OSVR_DeviceTokenObject::getSendGuard() {
return m_getSendGuard(); }
96 osvr::connection::DeviceUpdateCallback
const &cb) {
97 m_setUpdateCallback(cb);
101 m_preConnectionInteract = f;
105 if (m_preConnectionInteract) {
106 m_preConnectionInteract();
108 m_connectionInteract();
114 return m_ownedObjects.
release(obj);
118 std::string
const &jsonString) {
119 m_getConnectionDevice()->setDeviceDescriptor(jsonString);
120 m_getConnection()->triggerDescriptorHandlers();
123 ConnectionPtr OSVR_DeviceTokenObject::m_getConnection() {
return m_conn; }
129 void OSVR_DeviceTokenObject::m_stopThreads() {}
131 void OSVR_DeviceTokenObject::m_sharedInit(DeviceInitObject &init) {
132 m_conn = init.getConnection();
133 m_dev = m_conn->createConnectionDevice(init);
134 m_dev->setDeviceToken(*
this);
135 m_serverInterfaces = init.getServerInterfaces();
136 for (
auto &iface : m_serverInterfaces) {
137 iface->registerMessageTypes(*
this);
void setUpdateCallback(osvr::connection::DeviceUpdateCallback const &cb)
Sets the update/wait callback.
void getNow(TimeValue &tv)
Set the given TimeValue to the current time.
shared_ptr< Connection > ConnectionPtr
How one must hold a Connection.
void stopThreads()
Stop any threads spawned and owned by this DeviceToken.
Structure used internally to construct the desired type of device.
bool release(void *ptr)
Releases the indicated smart pointer in our ownership, if we have it.
Base class for connection-specific message type registration.
void connectionInteract()
Interact with connection. Only legal to end up in ConnectionDevice::sendData from within here somehow...
A device token for a device that does not have a standard update or wait callback - for instance...
bool releaseObject(void *obj)
Frees some object whose lifetime is controlled by the client context.
void setDeviceDescriptor(std::string const &jsonString)
Send a new or updated device descriptor for this device.
void setPreConnectionInteract(EventFunction const &f)
Sets a function to be executed at the beginning of connectionInteract()
shared_ptr< ConnectionDevice > ConnectionDevicePtr
How to hold on to a ConnectionDevice.
void sendData(osvr::connection::MessageType *type, const char *bytestream, size_t len)
Send data.
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
std::string const & getName() const
Accessor for name property.
static osvr::connection::DeviceTokenPtr createSyncDevice(osvr::connection::DeviceInitObject &init)
Creates a device token (and underlying ConnectionDevice) that has an update method that runs in the s...
static osvr::connection::DeviceTokenPtr createVirtualDevice(std::string const &name, osvr::connection::ConnectionPtr const &conn)
Creates a device token (and underlying ConnectionDevice) without a traditional, built-in update metho...
virtual ~OSVR_DeviceTokenObject()
Destructor.