Session Manager
1. Overview
The SessionManager is the central orchestrator of the HoloMIT networking architecture. It acts as the gateway for users to create, discover, join, and leave networked sessions. It handles the lifecycle of the session and dictates the Master/Client relationship.
It is split into two layers: the high-level Controller for Unity-side logic, and the low-level Wrapper for network transport.
2. SessionManagerController (High-Level API)
The SessionManagerController implements the ISessionManagerInterface. It is a Singleton that persists across scenes (DontDestroyOnLoad).
2.1. Core Responsibilities
- Session Lifecycle: Exposes methods to create (
CreateSession), join (JoinSession), initialize (InitSession), and leave (LeaveSession) the volumetric rooms. - Core Data Management: Updates the
CoreController.Instance.MySessionandSelfUserobjects based on the server's responses. - Event Dispatching: Exposes C#
Actiondelegates (e.g.,OnPlayerJoinedSessionEvent,OnPlayerLeavedSessionEvent) that other systems (like the ) listen to.
3. SessionManagerWrapper (Low-Level Transport Layer)
To decouple Unity logic from network protocols, the SessionManagerWrapper handles all direct communication with the backend.
3.1. REST API Requests (HTTP)
It uses an internal HttpManager to perform stateless operations:
POST /api/createSession/POST /api/joinSession/GET /api/sessions/(Retrieve available rooms)
3.2. Real-Time Events (Socket.IO)
Once a session is joined, the Wrapper establishes a persistent WebSocket connection to the specific session namespace (/sessions/{sessionId}). It listens to real-time events like:
onUserJoinedSessiononUserLeavedSessionchangeLod
These JSON payloads are parsed into C# structs (like JsonResponse or Player) and passed back to the Controller via the interface.
4. Public API Reference (Controller)
public void JoinSession(uint _sessionId, string _playerName, UserRepresentationType _playerRepresentationType)Initiates the joining sequence, registering the user in the server database and assigning a Player ID._sessionId(uint): The unique numerical identifier of the session the user wants to join._playerName(string): The display name that the user will use during this session._playerRepresentationType(UserRepresentationType): An enum defining how the user is represented visually in the room (e.g.,None,PC,VR).
public void GetSessions()Requests a list of all active sessions, triggeringOnGetSessionsEventupon success.