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 IServiceAdapter

Remarks

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

Goal
How

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.

Parameter
Type
Description

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.

Parameter
Type
Description

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.

Parameter
Type
Description

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:

  1. Return a valid NetworkServiceType from ServiceType

  2. Call Initialize() before any other methods are used

  3. Return a fully-connected NetworkSession from CreateSession() and JoinSession() (i.e., the client connection must be established before returning)

  4. Return a valid NetworkUser with non-null ID and Name from SignIn()

You SHOULD:

  • Handle platform-specific cleanup in SignOut()

  • Support the queryOptions parameter in QuerySessions() for filtering

  • Wait for player synchronization before returning from session methods

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

Last updated