Moongate.Network.Packets 0.4.1

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

Moongate

Moongate.Network.Packets

Ultima Online packet definitions, span-based serialization, and packet registration for Moongate.

Installation

Requires .NET 10. Use the package version available in your configured NuGet feed.

dotnet add package Moongate.Network.Packets

Features

  • An initial packet set targeting ClassicUO 7.x, including login, control, ping, and supported-feature messages.
  • A packet registry using packet metadata for registration and opcode lookup.
  • Span-based readers and writers for packet serialization.
  • Encoding and decoding APIs that can be tested independently of a TCP server.

Example

Register the ping packet, freeze the registry, and decode an encoded frame:

using Moongate.Network.Packets.General;
using Moongate.Network.Packets.Registry;
using Moongate.Network.Packets.Serialization;

var registry = new PacketRegistry();
registry.RegisterPacket<PingPacket>();
registry.Freeze();

var bytes = PacketCodec.Encode(new PingPacket(42));

if (!registry.TryDecode(bytes, out var packet, out var opCode)
    || packet is not PingPacket ping)
{
    throw new InvalidOperationException($"Could not decode opcode {opCode:X2}.");
}

Console.WriteLine($"{opCode:X2}:{ping.Sequence}");

See Packets and handlers for the complete built-in opcode table, a custom packet, byte-level tests and host integration.

Binary span utilities

These additional helpers were introduced on develop after version 0.4.0. Use a source reference or a release containing the addition.

Moongate.Network.Packets.Spans also exposes SpanReader, SpanWriter, and SpanOwner for standalone binary serialization. They support signed and unsigned primitives, big- and little-endian values, ASCII/UTF-8/UTF-16 strings, seeking, and packet-length patching. SpanReader provides throwing reads and strict TryRead methods.

For generic string reads and writes, fixedLength describes a field in encoding units: bytes for ASCII/UTF-8, 16-bit units for UTF-16, and 32-bit units for UTF-32. The legacy writer truncates the input to at most fixedLength UTF-16 code units, then encodes and zero-pads the field. If that prefix exceeds the encoded field width, it throws before modifying the destination.

Construct a SpanWriter with a caller-owned Span<byte> for a fixed buffer, or with an initial capacity to rent a pooled buffer. Pass resize: true to enable growth. EnsureCapacity reserves total capacity; EnsureRemainingCapacity reserves space after the current cursor. ToArray copies the written payload; ToSpan transfers a pooled buffer to a disposable SpanOwner (or copies a caller-owned buffer) and resets the writer.

Dispose writers in a finally block and dispose each returned owner after use. Pass pooled writers by ref: copying them would duplicate ownership of the same buffer. Do not retain spans across growth, ownership transfer, or disposal.

Existing packet implementations continue to use PacketReader and PacketWriter. Their public signatures and fixed-buffer behavior are unchanged; use the standalone helpers when writing binary data outside those packet contracts.

Dependencies and scope

This package depends on Moongate.Core. It does not require Moongate.Network to encode or decode packets.

The packet set is a subset of the UO protocol. Decoding expects a complete packet frame; buffering and framing a TCP stream belong to the transport integration. Packet handlers and game-loop dispatch belong to the server integration.

License and source

Licensed under AGPL-3.0-or-later. See the source repository and license.

Product Compatible and additional computed target framework versions.
.NET 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 (1)

Showing the top 1 NuGet packages that depend on Moongate.Network.Packets:

Package Downloads
Moongate.Server.Core

Plugin-facing server contracts, events, registries, and dependency injection extensions for Moongate.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.19.0 0 10/16/2026
0.18.0 1 10/16/2026
0.17.0 111 10/14/2026
0.16.0 104 10/9/2026
0.15.0 102 10/7/2026
0.14.0 110 10/4/2026
0.13.0 106 10/3/2026
0.12.0 111 10/2/2026
0.11.0 119 9/30/2026
0.10.0 121 9/30/2026
0.9.0 123 9/27/2026
0.8.0 113 9/26/2026
0.7.0 103 9/24/2026
0.6.0 115 9/21/2026
0.5.0 110 9/20/2026
0.4.1 119 9/20/2026
0.4.0 112 9/19/2026
0.3.0 103 9/18/2026
Loading failed