NetSquare.Core 1.0.6

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

NetSquare.Core

NetSquare.Core contains the shared primitives used by NetSquare.Client and NetSquare.Server: network messages, serialization helpers, dispatcher routing, compression and encryption abstractions, protocol helpers, UDP client support, and synchronization frames.

The package targets .NET Standard 2.0, .NET 8, and .NET Framework 4.8. It is installed automatically when you install NetSquare.Client or NetSquare.Server 1.0.6 and later.

Installation

NuGet\Install-Package NetSquare.Core -Version 1.0.6

or:

dotnet add package NetSquare.Core --version 1.0.6

Network Messages

Use NetworkMessage to write values in the order the receiver will read them.

using NetSquare.Core;

public enum GameMessage : ushort
{
    Chat = 1,
    Ping = 2
}

NetworkMessage message = new NetworkMessage(GameMessage.Chat)
    .Set("hello")
    .Set(123)
    .Set(true);

string text = message.Serializer.GetString();
int number = message.Serializer.GetInt();
bool enabled = message.Serializer.GetBool();

Supported helpers include numeric primitives, strings, chars, booleans, byte arrays, numeric arrays, INetSquareSerializable objects, lists, and dictionaries.

Dispatcher

Register handlers manually:

NetSquareDispatcher dispatcher = new NetSquareDispatcher();

dispatcher.AddHeadAction(GameMessage.Chat, "Chat", message =>
{
    string text = message.Serializer.GetString();
});

Or auto-bind public static methods with NetSquareActionAttribute:

public static class Handlers
{
    [NetSquareAction(GameMessage.Chat)]
    public static void OnChat(NetworkMessage message)
    {
        string text = message.Serializer.GetString();
    }
}

Serialization

Implement INetSquareSerializable when a type should control its own binary representation.

public sealed class PlayerState : INetSquareSerializable
{
    public string Name;
    public int Score;

    public void Serialize(NetSquareSerializer serializer)
    {
        serializer.Set(Name);
        serializer.Set(Score);
    }

    public void Deserialize(NetSquareSerializer serializer)
    {
        Name = serializer.GetString();
        Score = serializer.GetInt();
    }
}

Compression and Encryption

NetSquare.Core includes reusable compression and encryption implementations such as NoCompression, GZipCompressor, DeflateCompressor, NoEncryption, AES_Encryptor, and XOR_Encryptor.

Synchronization Frames

The synchronization frame types are shared by the client and server world managers.

INetSquareSynchFrame frame = new NetsquareTransformFrame(
    _x: 10,
    _y: 0,
    _z: 5,
    _time: 1.25f);

License

MIT

Product 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 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 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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on NetSquare.Core:

Package Downloads
NetSquare.Server

NetSquare as a verry fast and easy to use .NET Tcp/Udp solution for Server/client developpment. Unity compatible

NetSquare.Client

NetSquare as a verry fast and easy to use .NET Tcp/Udp solution for Server/client developpment. Unity compatible

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.7 48 5/30/2026
1.0.6 145 5/18/2026

Initial standalone core package split from NetSquare.Client and NetSquare.Server.