bruce48x/Lakona / skills/lakona-integrate-game-client
lakona-integrate-game-client
VerifiedIntegrate or update a generated Lakona Game client in Unity, Godot, or .NET applications, including connection progress, business login, automatic recovery, callback dispatch, and disposal. Use for client connection UI or reconnect behavior; server session cleanup belongs to the session lifecycle skill.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.7 KB |
| agents/openai.yaml | config | 278 B |
| references/client-ui-shapes.md | markdown | 4.2 KB |
references/client-ui-shapes.md
View on GitHub# Client Connection UI Shapes
Adapt these shapes to the discovered generated namespace, callback receiver,
business contracts, transport, serializer, and engine dispatcher.
## Recovery-capable Construction
```csharp
// createTransport returns a NEW ITransport with the same endpoint/security setup.
Func<ITransport> createTransport = CreateConfiguredTransport;
var options = new LakonaGameClientOptions(createTransport, serializer);
var gameClient = new LakonaGameClient(options, callbackReceiver);
await gameClient.ConnectAsync(cancellationToken);
// Now invoke the project's login RPC through gameClient.Api.
// Only its successful business response establishes authenticated UI state.
```
Use `Lakona.Game.Client` and `Lakona.Rpc.Core` imports plus the project's
generated client namespace. `CreateConfiguredTransport` is application code,
not a framework method. The owner retains `gameClient` until logout/shutdown
and awaits `DisposeAsync` there; a short-lived login method must not dispose
the client on return.
## Unity Event Presentation
Run state rendering on the main thread. This partial presenter assumes an
existing client owner; helper methods below are application UI methods. Add
`System`, `System.Collections.Concurrent`, and `Lakona.Game.Client` imports.
```csharp
private readonly ConcurrentQueue<(LakonaGameClient Owner, LakonaGameConnectionStateChange Change)> _connectionChanges
= new ConcurrentQueue<(LakonaGameClient, LakonaGameConnectionStateChange)>();
private Action<LakonaGameConnectionStateChange> _stateChanged;
// Call on the main thread for the new owner, before ConnectAsync.
private void AttachConnectionState(LakonaGameClient client)
{
_stateChanged = change => _connectionChanges.Enqueue((client, change));
client.ConnectionStateChanged += _stateChanged;
RenderConnectionState(client.ConnectionState);
}
// Call on the main thread before discarding or replacing the current owner.
private void DetachConnectionState()
{
if (_gameClient != null && _stateChanged != null)
_gameClient.ConnectionStateChanged -= _stateChanged;
_stateChanged = null;
}
private void Update()
{
ApplyPendingCallbacks(); // Drain the project's thread-safe callback inbox.
while (_connectionChanges.TryDequeue(out var item))
{
if (ReferenceEquals(item.Owner, _gameClient))
RenderConnectionState(item.Change.CurrentState);
}
}
private void RenderConnectionState(LakonaGameConnectionState state)
{
switch (state)
{
case LakonaGameConnectionState.Created:
ShowConnectionStatus("Ready to connect");
break;
case LakonaGameConnectionState.Connecting:
ShowConnectionStatus("Connecting");
break;
case LakonaGameConnectionState.Connected:
ShowConnectionStatus("Connected");
// Login and world readiness remain owned by business responses.
break;
case LakonaGameConnectionState.Reconnecting:
ShowConnectionStatus("Reconnecting");
// Keep the current match/world until recovery or terminal failure.
break;
case LakonaGameConnectionState.Disconnected:
ShowConnectionStatus("Recovery failed");
break;
case LakonaGameConnectionState.Disposed:
ShowConnectionStatus("Connection closed");
break;
}
}
```
Detach the handler before replacing the owner and attach to the new one. Set
`_gameClient` to the new owner (or null) before draining queued events. Queued
notifications from the old owner are ignored. Gate business controls using connection,
authentication, world readiness, and pending-request state together. Recheck
ownership when applying queued callbacks or async results; a callback from an
old client must not update the new login. Do not retry a non-idempotent business
request merely because connection state returns to `Connected`.
Use the equivalent main-thread presenter/update mechanism in Godot or another
engine. `ConnectionState` is framework observation; it does not own engine UI.
For older clients without the event, query `ConnectionState` from the existing
main-thread presenter and render when it changes. For controls that require the
latest availability, read the current property rather than a queued transition.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |