Altruist.Client
0.10.1-beta
dotnet add package Altruist.Client --version 0.10.1-beta
NuGet\Install-Package Altruist.Client -Version 0.10.1-beta
<PackageReference Include="Altruist.Client" Version="0.10.1-beta" />
<PackageVersion Include="Altruist.Client" Version="0.10.1-beta" />
<PackageReference Include="Altruist.Client" />
paket add Altruist.Client --version 0.10.1-beta
#r "nuget: Altruist.Client, 0.10.1-beta"
#:package Altruist.Client@0.10.1-beta
#addin nuget:?package=Altruist.Client&version=0.10.1-beta&prerelease
#tool nuget:?package=Altruist.Client&version=0.10.1-beta&prerelease
Altruist.Client
Drop-in client for any Altruist server. Speaks the same wire protocol the server speaks — TCP / UDP / WebSocket framing, MessagePack or JSON codec, gate-name dispatch, fixarray(3) envelope. Use it from Unity, Godot, Blazor, console games, headless integration test harnesses — anywhere netstandard2.1 runs.
Install
<PackageReference Include="Altruist.Client" Version="0.9.5-beta" />
For Unity, build the DLL and drop it (and Altruist.Protocol.dll, MessagePack.dll) into Assets/Plugins/.
Wire shape (read-only reference)
| Step | Bytes |
|---|---|
| Server→client handshake (TCP only) | [4 LE length][UTF-8 clientId] |
| Framing both directions (TCP) | [4 LE length][payload] |
| Client→server payload | [1 byte gateLen][gate UTF-8][codec(packet)] |
| Server→client payload | codec-encoded MessageEnvelope = fixarray(3) [MessageCode (uint), Header, Message] |
The package owns this shape. Don't reimplement it in the consumer.
Three transports
| Class | Use |
|---|---|
AltruistTcpClient |
Login, gameplay, anything ordered. Background read thread → IncomingQueue. |
AltruistUdpClient |
Movement, voice, anything droppable. |
AltruistWebSocketClient |
Browser clients, JSON debug. |
All three share the same lifecycle surface: OnConnected, OnDisconnected, OnError(Exception), IsConnected, ClientId. All async APIs accept a CancellationToken.
Wiring
using Altruist;
using Altruist.Client;
var endpoint = new EndpointConfig("127.0.0.1", 13000, "messagepack");
var codec = MessagePackClientCodec.Instance;
var router = new PacketRouter(codec);
router.Register<DamageInfo>(PC.Damage, OnDamage);
router.Register<SCharacterAdd>(PC.CharacterAdd, OnCharacterAdd);
await using var tcp = new AltruistTcpClient(endpoint, codec);
await tcp.ConnectAsync(); // handshake reads ClientId
tcp.StartReadLoop(); // pumps frames into IncomingQueue
// In your main loop / Update tick:
while (tcp.IncomingQueue.TryDequeue(out var payload))
router.Dispatch(payload);
await tcp.SendAsync("login", new CLogin { Username = "alice" });
void OnDamage(DamageInfo d) { /* … */ }
void OnCharacterAdd(SCharacterAdd c) { /* … */ }
AOT support
The receive path NEVER deserializes the outer envelope as a struct — MessageEnvelopeShape byte-skips the fixarray(3), peeks element [0] (MessageCode), slices element [2] (the inner packet bytes). Then MessagePackSerializer.Deserialize<T>(slicedBytes, options) is invoked with the concrete T registered for that MessageCode. Both operations are AOT-safe given a registered formatter for T.
Game-specific packet formatters are the consumer's responsibility:
var resolver = MessagePack.Resolvers.CompositeResolver.Create(
GeneratedResolver.Instance, // your mpc-generated formatters
StandardResolver.Instance);
var options = MessagePackSerializerOptions.Standard.WithResolver(resolver);
var codec = new MessagePackClientCodec(options);
The default MessagePackClientCodec.Instance uses reflection-friendly resolvers (works on Mono / .NET, fails on stripped IL2CPP / NativeAOT for game-specific packets without registered formatters).
Gotchas
- Resolver must match the server. If the server adds a custom
IMessagePackFormatterfor some type, the client codec needs the same formatter or wire-incompatible bytes follow. - Two registrations of the same MC silently overwrite. Last
Registerwins. Mirrors server[Service]last-wins. - Concurrent
SendAsyncis safe.AltruistTcpClientlocks the underlying stream so multi-thread send won't interleave bytes (a real production bug we caught in tests). StartReadLoopis mutually exclusive withDrainAsync. The first runs a background thread that enqueues intoIncomingQueue; the second is for tests that want to await batches. Pick one per consumer.
| 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 was computed. 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 is compatible. 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. |
-
.NETStandard 2.1
- Altruist.DI (>= 0.10.1-beta)
- Altruist.Protocol (>= 0.10.1-beta)
- MessagePack (>= 3.1.10)
-
net9.0
- Altruist.DI (>= 0.10.1-beta)
- Altruist.Protocol (>= 0.10.1-beta)
- MessagePack (>= 3.1.10)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Altruist.Client:
| Package | Downloads |
|---|---|
|
Altruist.Client.Inventory
Client-side inventory mirror for the Altruist wire protocol. Receives ItemSnapshotPacket frames, maintains per-container state with multi-cell coverage tracking, and surfaces SlotChanged / SlotCleared events for UI consumers. Game-specific item fields ride in an opaque payload; the framework never inspects them. Drop-in for Unity, Godot, or any .NET client that already speaks Altruist. |
|
|
Altruist.Testing
xUnit test framework override that resolves test classes marked [AltruistTest] from the real Altruist DI container. Constructor parameters tagged [Mock] are replaced with Moq mocks visible to the rest of the per-class container. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.10.1-beta | 0 | 11/23/2026 |