This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the Talo Unity Package, a self-hostable game development SDK providing leaderboards, player authentication, event tracking, game saves, stats, live config, channels, and more. The package is distributed via Unity Asset Store, GitHub releases, and itch.io.
The codebase uses git submodules for dependency management (run git submodule update --init after cloning).
All Talo code is located in Assets/Talo Game Services/Talo/:
Runtime/- Core SDK implementationAPIs/- API client classes for each service (Events, Players, Leaderboards, Saves, Stats, etc.)Entities/- Data models (Player, GameSave, LeaderboardEntry, etc.)Requests/- Request payload classesResponses/- Response payload classesSocketRequests/&SocketResponses/- WebSocket message typesUtils/- Internal utilities (ContinuityManager, CryptoManager, SavesManager, etc.)Vendor/- Third-party dependencies (WebSocket client)Talo.cs- Main static entry point and API accessTaloManager.cs- MonoBehaviour managing lifecycle and timersTaloSocket.cs- WebSocket connection handlerTaloSettings.cs- ScriptableObject configuration
Tests/- NUnit test suiteSamples/- Demo scenes (Leaderboards, Saves, Authentication, Chat, etc.)
Talo.cs is the main static singleton providing access to all services (e.g., Talo.Players, Talo.Events, Talo.Saves). It initializes a TaloManager MonoBehaviour on first access, which persists across scenes.
All API classes inherit from BaseAPI.cs, which handles HTTP requests via Unity's UnityWebRequest. Each API class (e.g., PlayersAPI, SavesAPI) exposes public async methods returning typed responses.
The ContinuityManager queues failed network requests (POST/PUT/PATCH/DELETE) to disk and replays them when connectivity is restored. It excludes certain endpoints like /health-check and /players/auth.
The SDK supports offline operation via TaloSettings.offlineMode. When offline, requests are queued for continuity replay. The HealthCheckAPI monitors connectivity and triggers connection lost/restored events.
TaloSocket.cs manages WebSocket connections for real-time features (channels, presence). It uses the com.mikeschweitzer.websocket package (vendored in Runtime/Vendor/).
Events are batched and flushed on application quit/pause/focus loss. On WebGL, events flush every webGLEventFlushRate seconds (default 30s) due to platform limitations.
Player updates and save updates are debounced to prevent excessive API calls during rapid property changes. APIs that need debouncing inherit from DebouncedAPI<TOperation> (a generic base class) and define a DebouncedOperation enum for type-safe operation keys. The base class uses a dictionary to track multiple debounced operations independently.
The debounce is leading and trailing: the first call fires immediately (leading), and if further calls arrive during the debounce window they are coalesced into a single trailing call executed after the window closes. The window is defined by debounceTimerSeconds (default: 1s) and resets on each subsequent call.
To add debouncing to an API:
- Define a public
enum DebouncedOperationwith your debounced operations - Inherit from
DebouncedAPI<YourAPI.DebouncedOperation> - Call
Debounce(DebouncedOperation.YourOperation)to queue an operation - Implement
ExecuteDebouncedOperation(DebouncedOperation operation)with a switch statement - The base class's
ProcessPendingUpdates()is called byTaloManager.Update()every frame
Example: PlayersAPI defines enum DebouncedOperation { Update } and inherits from DebouncedAPI<PlayersAPI.DebouncedOperation>. When Player.SetProp() is called, it calls Debounce(DebouncedOperation.Update). The first call fires immediately; subsequent calls within the debounce window result in a single trailing API call at the end of the window.
Tests use Unity Test Framework with NUnit. Run via Unity Editor:
- Test Runner Window: Window > General > Test Runner
- Run All Tests: Select "PlayMode" or "EditMode" tab and click "Run All"
CI runs tests via GitHub Actions (.github/workflows/ci.yml) using Unity 6000.0.59f2.
The package is built via GitHub Actions (.github/workflows/create-release.yml) on tagged releases:
- Creates
talo.unitypackagefromAssets/Talo Game Services/**/* - Uploads to itch.io and GitHub releases
Version is stored in Assets/Talo Game Services/Talo/VERSION. A pre-commit hook (.git/hooks/pre-commit) automatically updates ClientVersion in BaseAPI.cs to match the VERSION file.
Settings are managed via a ScriptableObject asset (Resources/Talo Settings):
accessKey- API authentication keyapiUrl- Backend URL (default:https://api.trytalo.com)socketUrl- WebSocket URL (default:wss://api.trytalo.com)autoStartSession- Auto-authenticate with saved session tokenautoConnectSocket- Auto-connect WebSocket on startupcontinuityEnabled- Enable failed request replayofflineMode- Simulate offline for testingdebounceTimerSeconds- Debounce interval for player updates, saves, and health checks (default: 1s)
Talo.Runtime(TaloRuntime.asmdef) - Main runtime assemblyTalo.Tests(TaloTests.asmdef) - Test assembly with NUnit references
Players must be identified via Talo.Players.Identify() before using most APIs. The SDK stores the current alias in Talo.CurrentAlias and player in Talo.CurrentPlayer. Sessions are managed by SessionManager with tokens stored in PlayerPrefs.
The SDK detects when running under NUnit (checks for nunit.framework assembly) and enables test mode, which uses RequestMock instead of real HTTP calls.
RequestException- HTTP errorsPlayerAuthException- Authentication-specific errors with error codesSocketException- WebSocket errorsContinuityReplayException- Continuity replay failures
Game saves support local caching and offline operation via SavesManager. The manager handles loading, creating, updating, and deleting saves with automatic continuity support.
- Main branch:
develop - Submodules: Required for WebSocket dependency
- Pre-commit hook: Auto-updates version in BaseAPI.cs
- CI: Runs tests on every push
- Releases: Manual workflow dispatch creates Unity package and GitHub release