CoreGame.SharedMeta.Server.Core 0.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package CoreGame.SharedMeta.Server.Core --version 0.1.2
                    
NuGet\Install-Package CoreGame.SharedMeta.Server.Core -Version 0.1.2
                    
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="CoreGame.SharedMeta.Server.Core" Version="0.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CoreGame.SharedMeta.Server.Core" Version="0.1.2" />
                    
Directory.Packages.props
<PackageReference Include="CoreGame.SharedMeta.Server.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 CoreGame.SharedMeta.Server.Core --version 0.1.2
                    
#r "nuget: CoreGame.SharedMeta.Server.Core, 0.1.2"
                    
#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 CoreGame.SharedMeta.Server.Core@0.1.2
                    
#: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=CoreGame.SharedMeta.Server.Core&version=0.1.2
                    
Install as a Cake Addin
#tool nuget:?package=CoreGame.SharedMeta.Server.Core&version=0.1.2
                    
Install as a Cake Tool

SharedMeta

Framework for shared game meta-logic between Client and Server with deterministic replay.

Write game logic once in C# — it runs on the server (Orleans grains) and replays on the client (Unity / .NET) with optimistic execution, automatic rollback, and desync detection.

What You Can Build

Player profiles and progression — experience, levels, inventory, currencies. State is persisted per-player, changes are optimistic (instant on client, validated on server).

Turn-based and card games — shared game rules execute identically on both sides. Matchmaking, lobbies, multi-entity game sessions with deterministic random for shuffles and draws.

Cooperative and async multiplayer — one player's action modifies another player's state via cross-entity calls. Energy systems, trading, expeditions that span multiple entities.

Economy and resource systems — crafting, shops, timers, regeneration. Server-only random for loot drops and rewards (client can't predict or cheat). ServerPatch mode for bandwidth-efficient state diffs.

Live-ops and admin tools — server-side triggers push events to clients. Subscribers react to state changes. Hot-swappable transport (WebSocket or HTTP polling) and serializer (MemoryPack or MessagePack).

Quick Start (Unity)

1. Install the Package

Add to Packages/manifest.json:

{
  "dependencies": {
    "com.coregame.sharedmeta": "https://github.com/CoreGameIO/SharedMeta.git#v0.1.0"
  }
}

2. Open the Project Wizard

SharedMeta > Project Wizard in Unity menu.

Configure:

  • Project name — your shared namespace (e.g. MyGame.Shared)
  • State name — entity state class (e.g. PlayerProfile)
  • Transport — SignalR (WebSocket, real-time) or HTTP Polling (universal, no extra DLLs)
  • Serializer — MemoryPack (default) or MessagePack

The Dependencies section auto-detects and installs required packages (serializer, transport).

3. Generate Projects

Use the three generation tabs:

Tab Generates Output
Shared Project State class, service interface, implementation, .csproj Unity folder + .NET mirror with linked sources
Server Project ASP.NET Core server with Orleans, transport, auth Standalone .NET project
Client Scripts MetaGameClient.cs MonoBehaviour + logger Unity Assets folder

4. Run

# Start the server
cd MyGame.Server
dotnet run

# Press Play in Unity — MetaGameClient connects automatically

Quick Start (.NET only)

dotnet build SharedMeta.sln
dotnet run --project examples/CardGame_TheFool/CardGame.Server

Architecture

┌─────────────────────────────────────────────────────────────────┐
│  Meta Layer (SharedMeta.Core, YourGame.Shared)                  │
│  Business logic: services, state, [MetaService] / [MetaMethod]  │
│  Code generation: dispatchers, API clients, context injection   │
└─────────────────────────────────────────────────────────────────┘
                              ↕
┌─────────────────────────────────────────────────────────────────┐
│  Middleware Layer (SharedMeta.Client, SharedMeta.Server)        │
│  MetaContext, replay mechanism, execution modes                 │
│  (Optimistic / Server / Local / CrossOptimistic / ServerPatch)   │
└─────────────────────────────────────────────────────────────────┘
                              ↕
┌─────────────────────────────────────────────────────────────────┐
│  Serialization Layer (SharedMeta.Serialization.*)               │
│  IMetaSerializer, MemoryPack / MessagePack implementations      │
└─────────────────────────────────────────────────────────────────┘
                              ↕
┌─────────────────────────────────────────────────────────────────┐
│  Transport Layer (SharedMeta.Transport.*)                       │
│  IConnection: SignalR WebSocket, HTTP long-polling, InProcess   │
└─────────────────────────────────────────────────────────────────┘
                              ↕
┌─────────────────────────────────────────────────────────────────┐
│  Server Backend (SharedMeta.Server.Core, Orleans)               │
│  IMetaProvider<TState>, EntityGrain, SessionManager             │
└─────────────────────────────────────────────────────────────────┘

Each layer depends only on the layers above it. Swap serializers, transports, or backends without changing game logic.

Key Concepts

Define Shared State

[MemoryPackable, MessagePackObject]  // transport serialization (pick one or both)
[GenerateSerializer]                  // Orleans grain persistence
public partial class GameState : ISharedState
{
    [Id(0), Key(0), MemoryPackOrder(0)] public int Score { get; set; }
    [Id(1), Key(1), MemoryPackOrder(1)] public List<string> Items { get; set; } = new();
}
  • [MemoryPackable] — MemoryPack serializer (default, zero-copy)
  • [MessagePackObject] + [Key(n)] — MessagePack serializer (cross-platform, schema-flexible)
  • [GenerateSerializer] + [Id(n)] — Orleans grain state persistence

Choose one serializer or use both. The wizard configures this automatically.

Define a Service

[MetaService("IGameService")]
public interface IGameService
{
    [MetaMethod(ExecutionMode.Optimistic)]
    void AddItem(string itemId);

    [MetaMethod(ExecutionMode.Server)]
    void GrantReward(int amount);
}

Implement the Service

[MetaServiceImpl(typeof(IGameService))]
public partial class GameServiceImpl : IGameService
{
    // Context is injected by source generator
    public void AddItem(string itemId)
    {
        State.Items.Add(itemId);
    }

    public void GrantReward(int amount)
    {
        // ServerRandom only generates on server; client replays from payload
        int bonus = Context.ServerRandom!.Next(10);
        State.Score += amount + bonus;
    }
}

Execution Modes

Mode Client Server Use Case
Optimistic Executes immediately, rolls back on mismatch Authoritative execution UI-responsive actions (move, play card)
Server Waits for server response Executes with ServerRandom Loot drops, matchmaking, secrets
Local Local-only, no RPC UI state, client-side filtering
CrossOptimistic Executes on own state Routes to target entity's grain Cross-entity interactions
ServerPatch Receives state diff from server Sends patch instead of full state Large state, bandwidth optimization

Deterministic Random

// Optimistic random — same algorithm & seed on both sides
int roll = Context.Random!.Next(6) + 1;

// Server random — generated on server, replayed on client
int loot = Context.ServerRandom!.Next(100);

Client Usage

var client = new MetaClient(connection, serializer);
await client.ConnectAsync("player-123", "entity-456");

// Generated typed API client
var gameApi = client.GetService<IGameServiceApiClient>();
gameApi.AddItem("sword_01");

// Subscribe to state changes
client.OnStateChanged += state => UpdateUI((GameState)state);

Examples

CardGame "The Fool"

Multiplayer turn-based card game with matchmaking lobby. Two players, attack/defend mechanics, trump suit. Demonstrates: Optimistic execution for card plays, Server mode for deck shuffle, lobby system with triggers, multi-entity game state.

Expedition

Single-player dungeon exploration with procedural map generation. Demonstrates: CrossOptimistic calls between expedition and profile entities, energy/money economy, ServerPatch mode (optional), deterministic random for map generation, session reconnection.

Project Structure

Directory Description
Runtime/Core/ Core framework: attributes, interfaces, meta context, random
Runtime/Client/ Client-side dispatcher, message buffer, MetaClient
Runtime/Transport/ Conditional transport assemblies: HTTP Polling, SignalR client
Runtime/Serialization/ MemoryPack serialization
Runtime/Orleans.Stubs/ Stub attributes for Unity (no Orleans dependency)
Editor/ Project Wizard, pre-built source generator DLL
src/SharedMeta.Generator/ Source generator: dispatchers, API clients, context injection
src/SharedMeta.Server/ Server-side meta context and cross-entity calls
src/SharedMeta.Server.Core/ EntityGrain, MetaProvider, file storage, session management
src/SharedMeta.Orleans/ Orleans grain integration
src/SharedMeta.Transport.SignalR/ SignalR WebSocket transport
src/SharedMeta.Transport.HttpPolling/ HTTP long-polling transport
src/SharedMeta.Auth/ JWT authentication middleware
examples/ CardGame_TheFool, Expedition — full working examples
tests/ Integration and unit tests

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on CoreGame.SharedMeta.Server.Core:

Package Downloads
CoreGame.SharedMeta.Orleans

Orleans integration: LobbyGrain, OrleansLobbyRequester, Orleans serialization configuration.

CoreGame.SharedMeta.Debug

Debug and testing utilities: InProcessServer, InProcessConnection for network-free testing.

CoreGame.SharedMeta.Auth

JWT device-based authentication: AuthGrain, login endpoints, token service, entity access policies.

CoreGame.SharedMeta.Transport.HttpPolling

HTTP long-polling transport: server endpoints and HttpPollingConnection client for universal compatibility.

CoreGame.SharedMeta.Transport.SignalR

SignalR WebSocket transport: MetaHub (server) and SignalRConnection (client) with MessagePack binary protocol.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.6.0 35 4/3/2026
0.5.1 170 3/26/2026
0.5.0 154 3/26/2026
0.4.5 189 3/15/2026
0.4.3 186 3/15/2026
0.4.2 190 3/14/2026
0.4.0 187 3/14/2026
0.3.5 184 3/12/2026
0.3.4 185 3/12/2026
0.3.3 185 3/11/2026
0.3.2 168 3/8/2026
0.3.1 161 3/7/2026
0.3.0 164 3/6/2026
0.2.0 162 3/6/2026
0.1.3 175 3/2/2026
0.1.2 166 3/1/2026
0.1.0 173 3/1/2026