The Session Observer
Track events related to session creation using the SessionObserver class.
Read time 1 minuteLast updated 12 hours ago
You can use the
SessionObserverISessionISession.TypeUnityServicesUnity ServicesMultiplayerServicevoid OnAddingSessionStarted(AddingSessionOptions addingSessionOptions) { Debug.Log($"A session of type {addingSessionOptions.Type} is being added.");}void OnSessionAdded(ISession session) { Debug.Log($"A session of type {session.Type} has been added.");}void OnAddingSessionFailed(AddingSessionOptions addingSessionOptions, SessionException exception) { Debug.Log($"The addition of a session of type {addingSessionOptions.Type} has failed with message {exception.Message}.");}// ...async Task CreateSession() { async using (var sessionObserver = new SessionObserver("my-session-type")) { sessionObserver.AddingSessionStarted += OnAddingSessionStarted; sessionObserver.SessionAdded += OnSessionAdded; sessionObserver.AddingSessionFailed += OnAddingSessionFailed; var sessionOptions = new Sessionoptions(){ Type = "my-session-type" }.WithRelayNetwork(); await Multiplayer.Instance.CreateSessionAsync(sessionOptions); }}