xnetlib 1.0.0
See the version list below for details.
dotnet add package xnetlib --version 1.0.0
NuGet\Install-Package xnetlib -Version 1.0.0
<PackageReference Include="xnetlib" Version="1.0.0" />
paket add xnetlib --version 1.0.0
#r "nuget: xnetlib, 1.0.0"
// Install xnetlib as a Cake Addin #addin nuget:?package=xnetlib&version=1.0.0 // Install xnetlib as a Cake Tool #tool nuget:?package=xnetlib&version=1.0.0
Xnet library
This is a useful library that helps you write server/client apps with very simple code.
How to install
.NET CLI
:dotnet add package xnetlib --version 1.0.0
- Package Manager:
NuGet\Install-Package xnetlib -Version 1.0.0
- 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 | Versions 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. |
-
net7.0
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on xnetlib:
Package | Downloads |
---|---|
xnetlib.streams
extendable network library |
|
xnetlib.dsa
extendable network library |
|
xnetlib.hosting
extendable network library |
|
xnetlib.replika
extendable network library |
|
xnetlib.buckets
extendable network library |
GitHub repositories
This package is not used by any popular GitHub repositories.