Network

Networker

Build status NuGet

Networker

A simple to use TCP and UDP networking library for .NET, designed to be flexible, scalable and FAST.

Supported Frameworks

  • .NET Standard 2.0

Features

Installation

V3 is currently in pre-release. Get the latest build below. NuGet Package Manager

Install-Package Networker -IncludePrerelease

You must then install one of the following formatters

ZeroFormatter

Networker.Formatter.ZeroFormatter

Install-Package Networker.Formatter.ZeroFormatter

Protobuf-net

Networker.Formatter.ProtoBufNet

Install-Package Networker.Formatter.ProtoBufNet

Getting Started

Find more information about how to get started on our Wiki or view the Examples found inside the repository.

Example

Creating a server is easy…

var server = new ServerBuilder()
                .UseTcp(1000)
                .UseLogger<ConsoleLogger>()
                .SetLogLevel(LogLevel.Info)
                .UseZeroFormatter()
                .Build();

You can handle a packet easily using dependency injection, logging and built-in deserialisation.

public class PingPacketHandler : PacketHandlerBase<PingPacket>
{
    private readonly ILogger logger;

    public PingPacketHandler(ILogger logger)
    {
        this.logger = logger;
    }

    public override async Task Process(PingPacket packet, ISender sender)
    {
        this.logger.Debug("Received a ping packet from " + sender.EndPoint);
    }
}

Older Versions

Version 3 included a large rewrite and various breaking changes. To use V2 please see V2 Branch