# IDeviceClient

<Badge tone="type">interface</Badge> <Badge>thread-safe</Badge>

```csharp
namespace AR51.Net;

public interface IDeviceClient
```

The apps and devices connected to the AR 51 system: headsets, Unity and Unreal apps, phones and Mocap Studio. Use it through [`IAR51Client.Devices`](/docs/sdk-api/csharp-api/classes/iar51client/). Read-only.

`Devices` follows the system live; all members are safe to use from any thread.

:::tip[How-to]
This page is **reference** (facts only). For a walkthrough with a complete sample, see the [Devices guide](/docs/csharp-api/servers-and-devices/).
:::

## Properties

<div className="apiPropTable apiTable">

| Property | Type | Access | Description |
|---|---|---|---|
| `Devices` | [`IReadOnlyList<DeviceInfo>`](#deviceinfo) | `get` | The connected devices. Empty while not connected. |

</div>

## Events

Standard .NET events (`EventHandler<T>`): subscribe with `+=`, unsubscribe with `-=`. They are raised on a background thread.

<div className="apiTable">

| Event | Args | Raised when |
|---|---|---|
| `DevicesChanged` | [`DevicesChangedEventArgs`](#deviceschangedeventargs) | Raised when a device connects or disconnects, or a battery level changes. Raised on a background thread. Battery levels are refreshed about every 10 seconds. |

</div>

<Example>

```csharp
ar51.Devices.DevicesChanged += (_, e) =>
{
    foreach (DeviceInfo device in e.Added) Console.WriteLine($"+ {device.Name} ({device.Platform})");
    foreach (DeviceInfo device in e.Removed) Console.WriteLine($"- {device.Name}");
};
```

</Example>

## Related types

Small types used by this interface, documented here.

### DeviceInfo

<Badge tone="type">record · sealed</Badge>

```csharp
public sealed record DeviceInfo(string Id, string Name, string Host, DeviceType Type, DevicePlatform Platform, int? BatteryPercent);
```

A device connected to the AR 51 system.

<div className="apiTable">

| Property | Type | Description |
|---|---|---|
| `Id` | `string` | The device's unique id. A skeleton's [`Skeleton.DeviceId`](/docs/sdk-api/csharp-api/classes/skeleton/) names the headset its person wears. |
| `Name` | `string` | The device's name, for example "Quest 3 - Player 2". |
| `Host` | `string` | The device's IP address. |
| `Type` | [`DeviceType`](#devicetype) | The kind of device. |
| `Platform` | [`DevicePlatform`](#deviceplatform) | The exact platform. |
| `BatteryPercent` | `int?` | Battery level from 0 to 100, or `null` when the device does not report it. |

</div>

### DeviceType

<Badge tone="type">enum</Badge>

```csharp
public enum DeviceType
```

The kind of a connected device.

<div className="apiTable">

| Value | Meaning |
|---|---|
| `Computer = 0` | A computer running an AR 51 app (Unity or Unreal). |
| `Headset = 1` | A VR, AR or mixed reality headset. |
| `Phone = 2` | A phone or tablet. |
| `MocapStudio = 3` | AR 51 Mocap Studio. |

</div>

### DevicePlatform

<Badge tone="type">enum</Badge>

```csharp
public enum DevicePlatform
```

The platform of a connected device.

<div className="apiTable">

| Value | Meaning |
|---|---|
| `Pc = 0` | A Windows, Linux or macOS computer. |
| `HoloLens = 1` | Microsoft HoloLens. |
| `HoloLens2 = 2` | Microsoft HoloLens 2. |
| `Android = 3` | An Android phone or tablet. |
| `MagicLeap = 4` | Magic Leap. |
| `OculusRift = 5` | Oculus Rift. |
| `MetaQuest = 6` | Meta Quest, running stand-alone. |
| `HtcVive = 7` | HTC Vive. |
| `OpenXrTethered = 8` | An OpenXR headset tethered to a computer. |
| `OpenXrMobile = 9` | A stand-alone OpenXR headset. |
| `PicoNeo3Pro = 10` | Pico Neo 3 Pro. |
| `MetaQuestLink = 11` | Meta Quest tethered to a computer (Quest Link). |
| `HtcFocus3 = 12` | HTC Vive Focus 3. |
| `MocapStudioWindows = 13` | Mocap Studio on Windows. |
| `MocapStudioLinux = 14` | Mocap Studio on Linux. |
| `MocapStudioMac = 15` | Mocap Studio on macOS. |

</div>

### DevicesChangedEventArgs

<Badge tone="type">class · sealed</Badge>

```csharp
public sealed class DevicesChangedEventArgs : EventArgs
```

Data for `IDeviceClient.DevicesChanged`.

<div className="apiPropTable apiTable">

| Property | Type | Access | Description |
|---|---|---|---|
| `Added` | [`IReadOnlyList<DeviceInfo>`](#deviceinfo) | `get` | Devices that connected. |
| `Removed` | [`IReadOnlyList<DeviceInfo>`](#deviceinfo) | `get` | Devices that disconnected. |
| `Devices` | [`IReadOnlyList<DeviceInfo>`](#deviceinfo) | `get` | Every connected device after the change, with current battery levels. |

</div>

<details>
<summary>Constructor</summary>

```csharp
public DevicesChangedEventArgs(IReadOnlyList<DeviceInfo> added, IReadOnlyList<DeviceInfo> removed, IReadOnlyList<DeviceInfo> devices);
```

Creates the event data.

</details>

## See also

- [Devices guide](/docs/csharp-api/servers-and-devices/) — walkthrough with a complete, compiled sample
- [Class index](/docs/sdk-api/csharp-api/classes/) — every AR51.Net type
- [Data conventions, threading and errors](/docs/csharp-api/conventions/)
