Working with Peers
Every participant in the session — devices and applications alike — is a peer. The peer API lets your application answer "who is here?", present itself well, and react to arrivals and departures. (Concept: The QAROS World.)
The C# snippets on this page are illustrative — they track the Quaternar.Qaros binding
surface but are not yet compiled from a published sample project.
Presenting your application
Your own peer's metadata is set at onboarding time via QarPeerPresentation (display name, app version, custom info string) and can be updated live:
qar_peer_update_display_name(session, "My CAD Tool — Assembly B");
The app_custom_peer_info field is yours: put a JSON blob or tag there to coordinate between instances of your own application across the session.
Enumerating peers
In C this is a count-then-fetch, like every enumeration in the API. The bindings run it for you: C# returns a ready-made array, Rust a Vec of owned snapshots.
size_t count = 0;
qar_result_log_if_error(qar_query_peer_specs_count(session, &count));
QarPeerSpec** specs = malloc(count * sizeof(*specs));
qar_result_log_if_error(
qar_query_peer_specs(session, specs, count, &count));
for (size_t i = 0; i < count; ++i)
{
char name[128];
qar_peer_spec_get_display_name(specs[i], name, sizeof(name));
/* also: _get_app_version, _get_app_custom_peer_info,
_get_presence, _get_version_id, _get_room_tag,
_get_id, _get_role, _get_category, _get_device_id,
_get_device_family, _get_device_name */
qar_peer_spec_handle_destroy(specs[i]);
}
free(specs);
Useful fields:
-
presence:
qar_peer_spec_get_presence()(in C#,PeerSpec.Presence; in Rust, raw only, as the Rust tab above shows): whether the peer is here. Render for, wait for and countQAR_PEER_PRESENCE_ONLINEandQAR_PEER_PRESENCE_UNKNOWNpeers; stop atOFFLINE,LEAVINGorRETIRED.Presence Means ONLINEthe hub sees the peer in the session OFFLINEthe hub no longer sees it: a crash, a kill, a network loss or a short drop. It reads ONLINEagain once it is backLEAVINGit announced a clean exit, and may come back under the same id RETIREDit left for good; query results no longer list it UNKNOWNthe hub has not reconciled it yet (an older hub that never reports presence, or one that just started); nothing says it is gone, so treat it like ONLINE -
app state (deprecated):
qar_peer_spec_get_app_state()/PeerSpec.AppStatestill work and are computed from the presence, but every peer readsQAR_APP_STATE_RUNNINGfrom the moment it joins, so the value never tells "loading" from "ready". Read the presence instead. -
room tag: which physical room the peer is in; lets multi-room deployments group peers.
-
qar_session_get_my_spec: your own peer's spec (e.g. to learn your assigned peer ID).
What a peer is: role, category and device
Every peer describes itself with five values. Read them from any QarPeerSpec with the C getters. In C#, PeerSpec carries them as properties; in Rust, they are raw only, through library.raw_api().
| Value | C getter | C# property | Example | Meaning |
|---|---|---|---|---|
| Role | qar_peer_spec_get_role | Role | QAR_PEER_ROLE_TARGET | What the peer does: SOURCE (renders or captures), TARGET (shows rendered content), RUNTIME (a Hub), CONTROL (a visualizer's control session), INTERNAL (pipeline infrastructure such as the mixer) |
| Category | qar_peer_spec_get_category | Category | QAR_DEVICE_CATEGORY_HEADSET | The kind of device: HEADSET, CAMERA, VISUALIZER, DESKTOP_PC, SERVER, or UNKNOWN |
| Device id | qar_peer_spec_get_device_id | DeviceId | "MetaQuest3" | The exact model, when known |
| Device family | qar_peer_spec_get_device_family | DeviceFamily | "MetaQuest" | The model's family |
| Device name | qar_peer_spec_get_device_name | DeviceName | "Meta Quest 3" | What to show the user |
- Render for peers whose role is
TARGET; the category and device only say what the target is. - Ids and families are open strings, not an enum: new models appear without a new QAROS SDK. Today's families include
HoloLens,MetaQuest,Metalens,Headset(a headset that has not reported a known model) andZed; treat this list as examples, never as complete. - Pick a picture or model by device id, else by family, else by category. An unknown model of a known family still matches its family; an unknown family still matches its category.
- A headset joins as itself and reports its exact model. The identity can still change while the peer runs: re-read it in your
qar_peer_subscribe_updatescallback instead of caching it. - The C string getters fill a caller buffer, like
qar_peer_spec_get_display_name. Text is UTF-8.
Show the user what each target is
QarPeerSpec* peers[64];
size_t written = 0;
qar_result_log_if_error(qar_query_peer_specs(session, peers, 64, &written));
for (size_t i = 0; i < written; ++i)
{
QarPeerRole role = QAR_PEER_ROLE_INTERNAL;
QarDeviceCategory category = QAR_DEVICE_CATEGORY_UNKNOWN;
char name[128] = "", family[64] = "";
if (qar_result_is_success(qar_peer_spec_get_role(peers[i], &role))
&& role == QAR_PEER_ROLE_TARGET)
{
qar_peer_spec_get_category(peers[i], &category);
qar_peer_spec_get_device_name(peers[i], name, sizeof(name)); /* "Meta Quest 3" */
qar_peer_spec_get_device_family(peers[i], family, sizeof(family)); /* "MetaQuest" */
show_target(name, icon_for(family, category)); /* your icon table, category as fallback */
}
qar_peer_spec_handle_destroy(peers[i]);
}
Pick a model for a headset in Unity
GameObject PrefabFor(PeerSpec peer) =>
headsetPrefabs.TryGetValue(peer.DeviceId, out var byModel) ? byModel // "MetaQuest3"
: headsetPrefabs.TryGetValue(peer.DeviceFamily, out var byFamily) ? byFamily // "MetaQuest"
: peer.Category == DeviceCategory.Camera ? genericCamera
: genericHeadset;
Describing your own device
An application is always a source (QAR_PEER_ROLE_SOURCE): it describes its device, never its role. By default QAROS publishes it as a desktop PC (DesktopWindows / DesktopLinux). To say more, chain a QarPeerDeviceIdentity on QarPeerPresentation::header.next when you onboard:
categorymust beQAR_DEVICE_CATEGORY_DESKTOP_PC,QAR_DEVICE_CATEGORY_SERVERorQAR_DEVICE_CATEGORY_CAMERA. Anything else fails withQAR_STATUS_PEER_DEVICE_CATEGORY_NOT_ALLOWEDand changes nothing.device_idis required.device_familyanddevice_nameare optional. An id the Hub's device catalog does not know is fine: the visualizer shows it by family or category, with your name.- Nothing is kept for you between starts: chain it on every onboard.
A source app that is a camera
QarPeerDeviceIdentity identity = {
.header = { .type = QAR_STRUCTURE_TYPE_PEER_DEVICE_IDENTITY },
.category = QAR_DEVICE_CATEGORY_CAMERA,
.device_id = "LuxonisOakD", /* unknown ids are fine */
.device_family = "Luxonis",
.device_name = "Luxonis OAK-D",
};
QarOnboardInit init = qar_onboard_init_default();
QarOnboardLocalAppExt local = qar_onboard_local_app_ext_default();
init.header.next = &local.header;
init.presentation.display_name = "Lab camera 1";
init.presentation.header.next = &identity.header;
QarOnboardingId unused = qar_onboarding_id_default();
QarSession* session = NULL;
QarResult r = qar_runtime_onboard(runtime, &init, NULL, NULL,
cancel, &unused, &session);
/* Joins as Source + Camera + LuxonisOakD. */
Refine the identity later
When the exact model is known only after your app opened the device, update it. Other peers see a normal peer update:
QarPeerDeviceIdentity refined = {
.header = { .type = QAR_STRUCTURE_TYPE_PEER_DEVICE_IDENTITY },
.category = QAR_DEVICE_CATEGORY_CAMERA,
.device_id = "LuxonisOakDPro",
.device_family = "Luxonis",
.device_name = "OAK-D Pro W",
};
qar_result_log_if_error(qar_peer_update_device_identity(session, &refined));
Declaring CAMERA changes how the visualizer lists and draws your peer. Streaming camera images and pose from a non-ZED camera needs a camera protocol QAROS does not offer yet.
Reacting to changes
static void on_peer_update(QarPeerSpec* peer, void* user_state)
{
/* peer joined / left / changed presentation or presence */
}
/* token is required: cancelling or destroying it ends the subscription */
qar_peer_subscribe_updates(session, on_peer_update, NULL, token);
Typical uses: refresh a "participants" panel, start a render stream when a target device appears, or pause expensive rendering when the last viewer leaves. Callback threading rules apply as everywhere: see API Conventions.