IServiceAdapter
Interface defining the contract for multiplayer service backends. Each implementation wraps a specific platform SDK (Unity Gaming Services, Steam, Epic) and exposes a unified async API for initialization, authentication, session querying, creation, and joining.
Definition
Namespace: Paragon.Core.Network
Assembly: Paragon.dll
public interface IServiceAdapterRemarks
IServiceAdapter is the core abstraction of the adapter subsystem. NetworkService holds a single adapter instance at runtime, selected by NetworkServiceType during Connect(). All multiplayer operations flow through this interface, making the rest of the network system agnostic to the underlying platform.
The interface is fully async — every method returns a Task or Task<T>. Implementations are expected to handle platform-specific initialization (e.g., UnityServices.InitializeAsync()) and authentication (e.g., anonymous sign-in) internally.
Currently, only UnityServiceAdapter provides a concrete implementation. The STEAM and EPIC values in NetworkServiceType are reserved for future adapter implementations.
Quick Lookup
Identify the backend
Read ServiceType property
Initialize the SDK
await adapter.Initialize()
Authenticate
await adapter.SignIn() → returns NetworkUser
List available sessions
await adapter.QuerySessions() → returns List<NetworkSessionInfo>
Create a new session
await adapter.CreateSession(name, maxConnections) → returns NetworkSession
Join an existing session
await adapter.JoinSession(sessionID) → returns NetworkSession
Sign out
await adapter.SignOut()
Properties
ServiceType
Identifies which multiplayer service this adapter wraps.
Returns: A NetworkServiceType enum value (UNITY, STEAM, or EPIC).
Methods
Initialize
Performs one-time SDK initialization for the service backend.
Behavior: Called once during NetworkService.Connect(). For Unity, this invokes UnityServices.InitializeAsync() after capturing thread context via UnityThreadUtils.
SignIn
Authenticates the local user with the service backend.
Returns: A NetworkUser record containing the authenticated user's ID and display name.
Behavior: For Unity, performs anonymous sign-in via AuthenticationService.Instance.SignInAnonymouslyAsync().
SignOut
Signs the local user out of the service backend.
Behavior: Completes asynchronously when the sign-out operation finishes. For Unity, listens for the SignedOut event on AuthenticationService.Instance.
QuerySessions
Queries the service for available multiplayer sessions.
queryOptions
QuerySessionsOptions
Optional filter/sort criteria. Defaults to null (no filter).
Returns: A list of NetworkSessionInfo structs, each containing session ID, name, and max player count.
CreateSession
Creates a new multiplayer session and returns a connected NetworkSession.
sessionName
string
Display name for the session. Falls back to "Paragon Session" if null.
maxConnections
int
Maximum number of players allowed. Defaults to 4.
Returns: A NetworkSession instance representing the created session. The caller is the session host/owner.
JoinSession
Joins an existing multiplayer session by its unique identifier.
sessionID
string
The unique identifier of the session to join.
Returns: A NetworkSession instance representing the joined session.
Implementation Requirements
When implementing IServiceAdapter, you MUST:
Return a valid
NetworkServiceTypefromServiceTypeCall
Initialize()before any other methods are usedReturn a fully-connected
NetworkSessionfromCreateSession()andJoinSession()(i.e., the client connection must be established before returning)Return a valid
NetworkUserwith non-nullIDandNamefromSignIn()
You SHOULD:
Handle platform-specific cleanup in
SignOut()Support the
queryOptionsparameter inQuerySessions()for filteringWait for player synchronization before returning from session methods
Common Pitfalls
QuerySessionsOptions dependency
The QuerySessions method uses Unity.Services.Multiplayer.QuerySessionsOptions as a parameter type. Future non-Unity adapters will need to either accept this type and map it internally, or the interface will need to be updated with a platform-agnostic query options type.
Initialization order
Initialize() must complete before calling SignIn(), and SignIn() must complete before calling session methods. NetworkService enforces this order, but direct adapter usage must follow the same sequence.
See Also
UnityServiceAdapter — concrete Unity Gaming Services implementation
Service Adapters — subsystem overview
NetworkManager — high-level entry point
Last updated