GameService.Sdk.LudoDoubles
1.0.0
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Standard 2.1
This package targets .NET Standard 2.1. The package is compatible with this framework or higher.
dotnet add package GameService.Sdk.LudoDoubles --version 1.0.0
NuGet\Install-Package GameService.Sdk.LudoDoubles -Version 1.0.0
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.LudoDoubles" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GameService.Sdk.LudoDoubles" Version="1.0.0" />
<PackageReference Include="GameService.Sdk.LudoDoubles" />
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.LudoDoubles --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: GameService.Sdk.LudoDoubles, 1.0.0"
#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.LudoDoubles@1.0.0
#: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.LudoDoubles&version=1.0.0
#tool nuget:?package=GameService.Sdk.LudoDoubles&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
GameService DoubleDice SDK
The DoubleDice SDK is a relay client for client-authoritative games. Game logic runs entirely on the Unity client — the server simply broadcasts data between all players in a room.
Installation in Unity
- Install NuGetForUnity
- Install NuGet packages:
GameService.Sdk.CoreGameService.Sdk.DoubleDiceprotobuf-net
- Or copy the source files into
Assets/Scripts/Sdk/
Quick Start
1. Connect & Create Client
using GameService.Sdk.Core;
using GameService.Sdk.LudoDoubles;
public class DoubleDiceManager : MonoBehaviour
{
private GameClient gameClient;
private LudoClient ludoClient;
private async void Start()
{
// Connect to GameService
gameClient = await GameClient.Create("https://your-server.com")
.WithAccessToken(accessToken)
.WithSynchronizationContext(true) // Ensures callbacks run on Unity main thread
.ConnectAsync();
// Create the DoubleDice client wrapper
ludoClient = new LudoClient(gameClient);
// Listen for data from other players
ludoClient.OnDataReceived += OnDataReceived;
}
private void OnDataReceived(string actionName, byte[] data)
{
// Handle incoming game data from other players
Debug.Log($"Received '{actionName}' ({data.Length} bytes)");
}
}
2. Room Management
// Create a room (uses a server-side template name)
var createResult = await ludoClient.CreateRoomAsync("DoubleDice");
if (createResult.Success)
Debug.Log($"Room: {createResult.RoomId}, Code: {createResult.ShortCode}");
// Join an existing room by short code or room ID
var joinResult = await ludoClient.JoinRoomAsync("12345");
if (joinResult.Success)
Debug.Log($"Joined at seat {joinResult.SeatIndex}");
// Matchmaking: auto-join an available room or create a new one
var matchResult = await ludoClient.CreateOrJoinRoomAsync("DoubleDice");
// Leave the room
await ludoClient.LeaveRoomAsync();
3. Sending Game Data
Use SendData to broadcast any data to all players in the room.
Raw Bytes
// Send raw byte array
byte[] myGameState = SerializeMyState();
var result = await ludoClient.SendData("Sync", myGameState);
if (result.Success)
Debug.Log("Data sent to all players!");
Protobuf Objects
Define your game messages with protobuf-net:
using ProtoBuf;
[ProtoContract]
public class DiceRollMessage
{
[ProtoMember(1)] public int Dice1 { get; set; }
[ProtoMember(2)] public int Dice2 { get; set; }
[ProtoMember(3)] public string PlayerId { get; set; }
}
// Send typed data (auto-serialized via protobuf)
var roll = new DiceRollMessage { Dice1 = 4, Dice2 = 6, PlayerId = "player1" };
await ludoClient.SendData("Roll", roll);
4. Receiving Game Data
All incoming data arrives via the OnDataReceived event:
ludoClient.OnDataReceived += (actionName, data) =>
{
switch (actionName)
{
case "Roll":
var roll = Deserialize<DiceRollMessage>(data);
Debug.Log($"Player {roll.PlayerId} rolled {roll.Dice1} + {roll.Dice2}");
break;
case "Sync":
ApplyGameState(data);
break;
case "Move":
var move = Deserialize<MoveMessage>(data);
AnimateToken(move);
break;
}
};
// Helper to deserialize protobuf messages
T Deserialize<T>(byte[] data)
{
using var ms = new MemoryStream(data);
return ProtoBuf.Serializer.Deserialize<T>(ms);
}
5. Player Events (via GameClient)
Player join/leave events come from the underlying GameClient:
gameClient.OnPlayerJoined += async (player) =>
{
Debug.Log($"{player.UserName} joined at seat {player.SeatIndex}");
};
gameClient.OnPlayerLeft += async (player) =>
{
Debug.Log($"{player.UserName} left the game");
};
gameClient.OnPlayerDisconnected += async (info) =>
{
Debug.Log($"{info.UserName} disconnected (grace: {info.GracePeriodSeconds}s)");
};
gameClient.OnPlayerReconnected += async (info) =>
{
Debug.Log($"{info.UserName} reconnected!");
};
API Reference
LudoClient
| Method | Description |
|---|---|
SendData(string action, byte[] data) |
Broadcast raw bytes to all room players |
SendData<T>(string action, T payload) |
Broadcast a Protobuf object to all room players |
CreateRoomAsync(string template) |
Create a new room |
JoinRoomAsync(string roomIdOrCode) |
Join by room ID or 5-digit short code |
CreateOrJoinRoomAsync(string template) |
Matchmaking: join available or create new |
LeaveRoomAsync() |
Leave the current room |
Events
| Event | Signature | Description |
|---|---|---|
OnDataReceived |
Action<string, byte[]> |
Fired when data is received. Args: (actionName, data) |
Architecture
Unity Client A Server Unity Client B
│ │ │
│ SendData("Roll", bytes) ──► │ │
│ │ ── GameEvent("Roll") ──────► │
│ │ (broadcast to room) │
│ ◄── OnDataReceived ──────── │ │
- Transport: SignalR (WebSockets)
- Serialization: Protobuf (binary, efficient for mobile)
- Server Role: Relay only — no game logic, no validation
- Thread Safety: Use
.WithSynchronizationContext(true)to receive callbacks on Unity's main thread
Important Notes
- The
actionNamestring is arbitrary — define whatever actions your game needs ("Roll","Move","Sync","Chat", etc.) - Data is opaque to the server — it forwards bytes without inspecting them
- The sender also receives their own
OnDataReceivedcallback - Use Protobuf for structured data (compact binary format, ideal for real-time games)
- Always call
LeaveRoomAsync()orgameClient.DisposeAsync()when done
| Product | Versions 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.
-
.NETStandard 2.1
- GameService.Sdk.Core (>= 1.0.8)
- protobuf-net (>= 3.2.56)
-
net8.0
- GameService.Sdk.Core (>= 1.0.8)
- protobuf-net (>= 3.2.56)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 88 | 2/23/2026 |