Skip to content

A simple to use TCP and UDP networking library for .NET. Compatible with Unity.

License

Notifications You must be signed in to change notification settings

n37r06u3/Networker

 
 

Repository files navigation

Build status NuGet

Networker

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

Contributing

Get involved and join us in Discord (https://discord.gg/NdEqhAe)

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

Tutorial - Creating a Basic Unity Multiplayer Game with Networker

Get started with this tutorial written by the library developer Mark Eastwood

Example

Creating a server is easy..

var server = new ServerBuilder()
                .UseTcp(1000)
                .UseUdp(5000)
                .RegisterPacketHandlerModule<DefaultPacketHandlerModule>()
                .RegisterPacketHandlerModule<ExamplePacketHandlerModule>()
                .UseZeroFormatter()
                .ConfigureLogging(loggingBuilder =>
                                    {
                                        loggingBuilder.AddConsole();
                                        loggingBuilder.SetMinimumLevel(
                                            LogLevel.Debug);
                                    })
                .Build();

server.Start();

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<PingPacketHandler> 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

About

A simple to use TCP and UDP networking library for .NET. Compatible with Unity.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%