xnetlib.dsa 1.0.1

dotnet add package xnetlib.dsa --version 1.0.1
NuGet\Install-Package xnetlib.dsa -Version 1.0.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="xnetlib.dsa" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add xnetlib.dsa --version 1.0.1
#r "nuget: xnetlib.dsa, 1.0.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.
// Install xnetlib.dsa as a Cake Addin
#addin nuget:?package=xnetlib.dsa&version=1.0.1

// Install xnetlib.dsa as a Cake Tool
#tool nuget:?package=xnetlib.dsa&version=1.0.1

Xnet library

This is a useful library that helps you write server/client apps with very simple code.

How to install

  1. .NET CLI: dotnet add package xnetlib --version 1.0.0
  2. Package Manager: NuGet\Install-Package xnetlib -Version 1.0.0
  3. Package Reference: <PackageReference Include="xnetlib" Version="1.0.0" />

Simple Example

The code below is everything.

class MyPacketProvider :  Xnet.BasicPacketProvider<MyPacketProvider>
{
    /// <summary>
    /// Test packet.
    /// </summary>
    private class PACKET : Xnet.BasicPacket
    {
        public override Task ExecuteAsync(Xnet Connection)
        {
            Console.WriteLine(Connection.IsServerMode
                ? "SERVER RECEIVED: PACKET!" 
                : "CLIENT RECEIVED: PACKET!");

            return Connection.EmitAsync(this);
        }

        protected override void Decode(BinaryReader Reader)
        {
        }

        protected override void Encode(BinaryWriter Writer)
        {
        }
    }

    /// <inheritdoc/>
    protected override void MapTypes()
    {
        Map<PACKET>("test");
    }
}

// ---

var Options = new Xnet.ServerOptions();

Options.Endpoint = new IPEndPoint(IPAddress.Any, 7800);
Options.NetworkId = Guid.Empty;
Options.PacketProviders.Add(new Program());

var Services = new ServiceCollection();
using var Provider = Services.BuildServiceProvider();

await Xnet.Server(Provider, Options, Token);

Clients can be implemented in exactly the same way, except that they use Xnet.ClientOptions and Xnet.Client methods for options.

To go more deeper...

Read Xnet/Xnet.Options.cs, Xnet/Xnet.Server.cs and Xnet/Xnet.Client.cs files. The comments on the Options class and derived classes included in these files will help you understand.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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. 
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 xnetlib.dsa:

Package Downloads
xnetlib.replika

extendable network library

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 160 10/20/2023