NetworkService
High-level orchestrator for the full multiplayer service lifecycle. Manages connecting to a backend platform, authenticating users, creating and joining sessions, kicking players, and tearing down connections. Owned by NetworkManager and accessed via NetworkManager.Service.
Definition
Namespace: Paragon.Core.Network Assembly: Paragon.dll
public class NetworkServiceRemarks
NetworkService delegates all platform-specific operations to an IServiceAdapter instance, which is created based on the NetworkServiceType passed to Connect(). Currently, only the Unity Gaming Services adapter (UnityServiceAdapter) is fully implemented; Steam and Epic adapters are stubbed behind preprocessor directives.
The class also manages the NetworkTransport component, adding the correct transport (e.g. UnityTransport, FacepunchTransport) to the Netcode NetworkManager GameObject.
Connection approval is handled internally by delegating to NetworkSession.OnConnectionApproval(), which validates that no duplicate user IDs join the same session.
Quick Lookup
Connect to backend
await service.Connect(NetworkServiceType.UNITY)
Sign in anonymously
await service.SignIn(NetworkServiceType.UNITY)
Quick start (auto join/create)
await service.QuickStart()
Create a session
await service.CreateSession("MySession", 4)
Join a session by ID
await service.JoinSession(sessionId)
Query available sessions
var sessions = await service.QuerySessions()
Leave current session
await service.LeaveSession()
Kick a player
await service.KickPlayer(player)
Full shutdown
service.Shutdown()
Check connection state
service.IsConnected, service.IsSignedIn, service.InSession
Properties
User
The currently authenticated user. null if not signed in.
Session
The current network session. null if not in a session.
IsConnected
true if a service adapter has been created (i.e. Connect() was called).
IsSignedIn
true if the user has authenticated via SignIn().
InSession
true if the user is currently in a session.
Events
OnJoinedSession
Invoked when the local user successfully creates or joins a session. Passes the NetworkSession instance.
OnLeftSession
Invoked when the local user leaves a session. Passes the NetworkSession instance.
Methods
Connect
Creates a platform-specific service adapter and transport layer, then initializes the adapter.
serviceType
NetworkServiceType
The backend platform to connect to
SignIn
Authenticates anonymously via the service adapter and stores the resulting NetworkUser. Sets the Netcode connection data payload.
serviceType
NetworkServiceType
The backend platform to sign in to
QuickStart
Queries for existing sessions and joins the first one found. If no sessions exist, creates a new one.
sessionName
string
Optional name for the session if one is created
QuerySessions
Queries the backend for available sessions.
queryOptions
QuerySessionsOptions
Optional filter/sort options for the query
Returns: A list of NetworkSessionInfo describing available sessions.
CreateSession
Creates a new multiplayer session and invokes OnJoinedSession.
sessionName
string
Optional display name for the session
maxConnections
int
Maximum number of players allowed (default: 4)
JoinSession
Joins an existing session by its ID and invokes OnJoinedSession.
sessionID
string
The unique identifier of the session to join
LeaveSession
Leaves the current session and invokes OnLeftSession. No-op if not in a session.
KickPlayer
Removes a player from the session and disconnects their client.
player
NetworkPlayer
The player to kick
KickPlayer both removes the player from the session via session.KickPlayer() and disconnects the client via NetworkManager.API.DisconnectClient(). Both operations are required.
SignOut
Deauthenticates from the backend service and clears the user reference.
Disconnect
Destroys the transport component and clears the service adapter. Synchronous operation.
Shutdown
Performs a full teardown in order: shuts down the session, signs out, then disconnects. No-op if not connected.
PrintSessionInfo
Runtime debug command that logs the current session's details (ID, name, max connections, host, players).
Common Pitfalls
Call Connect before SignIn The service adapter must be created via Connect() before SignIn() can authenticate. Calling SignIn() without a prior Connect() will throw a NullReferenceException.
Cannot change transport while listening SetTransportLayer() throws NotSupportedException if the Netcode NetworkManager is already listening. Shut down the network before switching service types.
Examples
Full Connection Flow
See Also
NetworkServiceType — enum selecting the backend platform
NetworkUser — authenticated user identity
NetworkManager — singleton that owns
NetworkServiceConnectionData — serializable user identity for connection payloads
NetworkPlayer — player record used in session management
Last updated