Connect to the HoloMetrix HUB
This examples shows how to discover devices, and connect to a device to get the RemoteSession instance.
Async device discovery
void Initialize()
{
Licenser.SetKey("my-license-key");
}
void FindAllAvailableHoloMetrixPoweredDevices()
{
Bluetooth.DeviceFound += MyDeviceFoundEventHandler;
Bluetooth.DeviceDiscoveryCanceled += MyDiscoveryCanceledEventHandler;
Bluetooth.DeviceDiscoveryComplete += MyDiscoveryCompleteEventHandler;
Bluetooth.BeginDeviceDiscovery();
}
void MyDeviceFoundEventHandler(object sender, DeviceDiscoveryEventArgs e)
{
// Do something with e.Device or e.Devices
// Update the UI
}
void MyDiscoveryCanceledEventHandler(object sender, DeviceDiscoveryEventArgs e)
{
Bluetooth.DeviceFound -= MyDeviceFoundEventHandler;
Bluetooth.DeviceDiscoveryCanceled -= MyDiscoveryCanceledEventHandler;
Bluetooth.DeviceDiscoveryComplete -= MyDiscoveryCompleteEventHandler;
// Do something with e.Device or e.Devices
// Update the UI
}
void MyDiscoveryCompleteEventHandler(object sender, DeviceDiscoveryEventArgs e)
{
Bluetooth.DeviceFound -= MyDeviceFoundEventHandler;
Bluetooth.DeviceDiscoveryCanceled -= MyDiscoveryCanceledEventHandler;
Bluetooth.DeviceDiscoveryComplete -= MyDiscoveryCompleteEventHandler;
// Do something with e.Device or e.Devices
// Update the UI
}
Connect to a device and launch an app
void ConnectToDiscoveredDevice(BluetoothDevice device)
{
if (device.TryConnectToHoloMetrixHubService())
{
// The connection is successful.
// Update the UI.
// Now we have access to RemoteSession.Instance .
}
else
{
// The session could not be started.
}
}
Launch an App
async void LaunchMyDesiredApp()
{
var myHoloMetrixApp = await RemoteSession.Instance.TryLaunchAppAsync<HoloMetrixApp>("myLaunchArgs");
// Do things with the app here.
}