Aller au contenu principal

Sessions

Qu'est-ce qu'une session?​

Une session est créée automatiquement lorsqu'un client WebSocket se connecte au port 10001. Une connexion = une session. Lorsque la connexion se ferme, la session est détruite et sa configuration est supprimée.

Chaque session comporte :

  • Un ID numérique (attribué automatiquement par le service)
  • Un nom de profil facultatif (que vous définissez)
  • Sa propre vue de chaque appareil : base, montage, préréglage, filtres et transformation de l'espace de travail

Plusieurs sessions peuvent coexister, par exemple votre application Unity sur une session et Haply Hub en observation sur une autre. Elles voient toutes le même appareil physique, mais avec leurs propres paramètres de coordonnées.

Définir un nom de profil​

Il est fortement recommandé de définir un nom de profil dans votre premier message :

{
"session": {
"configure": {
"profile": {
"name": "co.mycompany.myapp:1.4::main-scene"
}
}
}
}

Why it matters:

  • Haply Hub uses the profile name to recognise your simulation and let you tweak device settings (workspace, basis, mount, filters) from its UI.
  • Those tweaks are persisted — next time you run the same app, Hub automatically re-applies them without any code change on your side.
  • Other sessions (or HTTP clients) can target your session by profile name using a session selector: ?session=myapp:0. Profile selectors also accept * / ? glob wildcards, so a namespace like ?session=co.haply.hub::*:0 works without having to know the full profile.

Profile name format​

Recommended format: <app id>:<X.Y>[::<sub>]

PartWhatExample
<app id>Your application, as a reverse domain nameco.mycompany.myapp
<X.Y>Your application's version: major and minor only1.4
::<sub>Optional. Anything that tells sessions of the same app and version apart: a scene, an edition, a mode::main-scene, ::pro

Examples: co.mycompany.myapp:1.4, co.mycompany.myapp:1.4::main-scene, com.example.modeler:2026.3::pro.

  • The version lets Haply Hub tell your releases apart: a new release can get settings that fit it, while older releases keep theirs.
  • Major and minor only: a patch release keeps the same profile, and the settings saved for it.
  • The ::<sub> part comes last, so anything that matches on the app and version (co.mycompany.myapp:1.4, or a glob such as co.mycompany.myapp:*) still matches every sub-profile.
  • Keep <sub> non-numeric: in a session selector, a trailing :<integer> is read as the session index (?session=co.mycompany.myapp:1.4::main-scene:0 is the first session with that profile).

Remote control (cross-session configuration)​

A session's devices can be reconfigured from outside — by another WebSocket session, or by an HTTP client with no WebSocket connection at all. This is how Haply Hub tweaks your app's settings.

The HTTP client uses session selectors to target the right session:

# List all sessions
curl http://localhost:10001/sessions

# Look up a single session directly (path-form of the selector — same
# expressions as `?session=`, see Selectors for the full grammar)
curl http://localhost:10001/sessions/:myapp:0

# Change the basis on session with profile "myapp" (first match)
curl -X POST "http://localhost:10001/inverse3/0/config/basis?session=myapp:0" \
-H "Content-Type: application/json" \
-d '{"permutation": "XZY"}'

# Same, but target the first session in a namespace (profile wildcard)
curl -X POST "http://localhost:10001/inverse3/0/config/basis?session=co.haply.hub::*:0" \
-H "Content-Type: application/json" \
-d '{"permutation": "XZY"}'

Consultez le tutoriel HTTP de configuration à distance pour un exemple complet de contrôle HTTP inter-sessions.