Class SessionObserver
Implements
Inherited Members
Namespace: Unity.Services.Multiplayer
Assembly: Unity.Services.Multiplayer.dll
Syntax
public class SessionObserver : IDisposable
Remarks
Use this class to get events when a session is created, pending creation
or failed to be created for a specific session type.
It is possible
to create this class independently of the Unity.Services.Core.UnityServices
being initialized, allowing independent system in a project to track
session related events without handling the Unity.Services.Core.UnityServices
and MultiplayerService states themselves.
Constructors
SessionObserver(string)
Creates a new SessionObserver instance that will track
the creation of a session of the given sessionType
.
Declaration
public SessionObserver(string sessionType)
Parameters
Type | Name | Description |
---|---|---|
string | sessionType | The Type to track. |
SessionObserver(string, IUnityServices)
Creates a new SessionObserver instance that will track
the creation of a session of the given sessionType
.
Declaration
public SessionObserver(string sessionType, IUnityServices registry)
Parameters
Type | Name | Description |
---|---|---|
string | sessionType | The Type to track. |
IUnityServices | registry | Optional parameter to specify a custom Unity.Services.Core.IUnityServices to register to. |
See Also
Fields
SessionType
The session type tracked by this observer.
Declaration
public readonly string SessionType
Field Value
Type | Description |
---|---|
string |
Properties
Session
Returns the current ISession with a matching SessionType if it exists.
Declaration
public ISession Session { get; }
Property Value
Type | Description |
---|---|
ISession |
Methods
Dispose()
Cleans up all currently registered events tracking the SessionType sessions.
Declaration
public void Dispose()
Events
AddingSessionFailed
This event is called when the IMultiplayerService instance fails to create or join a ISession using a Type value equal to SessionType.
Declaration
public event Action<AddingSessionOptions, SessionException> AddingSessionFailed
Event Type
Type | Description |
---|---|
Action<AddingSessionOptions, SessionException> |
AddingSessionStarted
This event is called when the IMultiplayerService instance is starting to create or join a ISession using a Type value equal to SessionType.
Declaration
public event Action<AddingSessionOptions> AddingSessionStarted
Event Type
Type | Description |
---|---|
Action<AddingSessionOptions> |
SessionAdded
This event is called when a ISession is added successfully with a Type value equal to SessionType.
Declaration
public event Action<ISession> SessionAdded
Event Type
Type | Description |
---|---|
Action<ISession> |