GameService.Sdk.Core 1.0.8

dotnet add package GameService.Sdk.Core --version 1.0.8
                    
NuGet\Install-Package GameService.Sdk.Core -Version 1.0.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GameService.Sdk.Core" Version="1.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GameService.Sdk.Core" Version="1.0.8" />
                    
Directory.Packages.props
<PackageReference Include="GameService.Sdk.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GameService.Sdk.Core --version 1.0.8
                    
#r "nuget: GameService.Sdk.Core, 1.0.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GameService.Sdk.Core@1.0.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GameService.Sdk.Core&version=1.0.8
                    
Install as a Cake Addin
#tool nuget:?package=GameService.Sdk.Core&version=1.0.8
                    
Install as a Cake Tool

GameService SDK for Unity & .NET

This SDK provides a clean, strongly-typed client for connecting to the GameService backend. It is designed to be compatible with Unity 2021.3+ and standard .NET applications.

Compatibility

  • Target Framework: .NET Standard 2.1
  • Dependencies:
    • Microsoft.AspNetCore.SignalR.Client
    • protobuf-net
    • Newtonsoft.Json (Optional, internal use mostly)

Installation in Unity

  1. NuGet Packages: You need the DLLs for the dependencies. The easiest way is to use NuGetForUnity.
  2. Install Packages:
    • Microsoft.AspNetCore.SignalR.Client
    • protobuf-net
    • System.Text.Json (If not present in newer Unity versions)
  3. Copy SDK: Copy the source files from GameService.Sdk.Core, GameService.Sdk.Auth, etc., into your Unity Assets/Scripts/Sdk folder.

Usage

1. Authentication

// Initialize Auth Client
var auth = new AuthClient("http://localhost:5525");

// Login (Guest or Email)
var result = await auth.GuestLoginAsync();
if (result.Success) {
    Debug.Log($"Logged in! Token: {result.Session.AccessToken}");
}

2. Connect to Game Hub

// Connect using the session from auth
var gameClient = await result.Session.ConnectToGameAsync();

// Listen for events
gameClient.OnPlayerJoined += async (player) => {
    Debug.Log($"{player.UserName} joined seat {player.SeatIndex}");
};

3. Play a Game (e.g., Ludo)

// Create or Join
var ludo = await LudoClientFactory.CreateOnlineGameAsync(gameClient);

// Handle Game State
ludo.OnStateUpdated += (state) => {
    Debug.Log($"Current Player: {state.CurrentPlayer}");
};

// Actions
if (ludo.IsMyTurn) {
    await ludo.RollDiceAsync();
}

Architecture

  • Transport: SignalR (WebSockets)
  • Serialization: Protobuf (Binary) for game actions, JSON for metadata.
  • Thread Safety: Use WithSynchronizationContext(true) when building the client in Unity to ensure callbacks run on the main thread.

Get Started with Unity

The Core SDK handles SignalR connections and real-time communication.

Key Classes

  • GameClient: Main connection to GameService Hub
  • GameSession: Authentication session with token management
  • ConnectionState: Connection status tracking

Basic Connection

using GameService.Sdk.Core;

public class GameManager : MonoBehaviour
{
    private GameClient gameClient;
    
    private async void Start()
    {
        // Connect with access token
        gameClient = await GameClient.Create("https://your-server.com")
            .WithAccessToken(accessToken)
            .WithSynchronizationContext(true) // Unity main thread
            .ConnectAsync();
            
        // Listen for connection events
        gameClient.OnConnectionStateChanged += OnConnectionChanged;
        gameClient.OnLatencyUpdate += OnLatencyUpdate;
    }
    
    private async void OnConnectionChanged(ConnectionState state)
    {
        Debug.Log($"Connection: {state}");
    }
    
    private async void OnLatencyUpdate(int ms)
    {
        Debug.Log($"Latency: {ms}ms");
    }
    
    private async void OnDestroy()
    {
        if (gameClient != null)
            await gameClient.DisposeAsync();
    }
}

Room Management

// Create a new game room
var createResult = await gameClient.CreateRoomAsync("StandardLudo");
if (createResult.Success)
{
    Debug.Log($"Room created: {createResult.RoomId}");
    Debug.Log($"Short code: {createResult.ShortCode}");
}

// Join existing room
var joinResult = await gameClient.JoinRoomAsync("ABCDE"); // Short code or Room ID
if (joinResult.Success)
{
    Debug.Log($"Joined as seat {joinResult.SeatIndex}");
}

// Create or join a room (matchmaking)
// Searches for existing rooms sorted by player count, joins if available, otherwise creates a new room
var matchResult = await gameClient.CreateOrJoinRoomAsync("StandardLudo");
if (matchResult.Success)
{
    Debug.Log($"Joined as seat {matchResult.SeatIndex}");
}

// Leave room
await gameClient.LeaveRoomAsync();

Game Events

// Player events
gameClient.OnPlayerJoined += async (player) => 
{
    Debug.Log($"{player.UserName} joined seat {player.SeatIndex}");
};

gameClient.OnPlayerLeft += async (player) => 
{
    Debug.Log($"{player.UserName} left the game");
};

// Game state updates
gameClient.OnGameState += async (state) => 
{
    Debug.Log($"Game state updated: {state.PlayerCount} players");
};

// Chat messages
gameClient.OnChatMessage += async (message) => 
{
    Debug.Log($"{message.UserName}: {message.Message}");
};
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on GameService.Sdk.Core:

Package Downloads
GameService.Sdk.Ludo

Ludo game SDK for GameService - Type-safe Ludo game client with all game actions

GameService.Sdk.Auth

Authentication SDK for GameService - Login, register, token management

GameService.Sdk.LuckyMine

LuckyMine game SDK for GameService - Minesweeper-style betting game

GameService.Sdk.LudoDoubles

DoubleDice relay game SDK for GameService - client-authoritative multiplayer game

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.8 120 2/22/2026
1.0.7 86 2/22/2026
1.0.6 86 2/21/2026
1.0.5 130 2/16/2026
1.0.4 506 12/19/2025
1.0.3 367 12/19/2025
1.0.2 378 12/18/2025
1.0.1 374 12/18/2025
1.0.0 352 12/15/2025