Skip to content

A Networking Libary that is simple to use, but Flexible by Extensibility

License

Notifications You must be signed in to change notification settings

HurricanKai/FlexNet

Repository files navigation

FlexNet

A Networking Libary that is simple to use, but Flexible by Extensibility

Build status

Table of Contents

Downloads

All Packets are Aviable on Nuget, or in the Release Section Below is a Table of all Nuget Packets

Name Package Manager
Core Install-Package FlexNet.Core
Default Accessors Install-Package FlexNet.Core.DefaultAccessors
SimpleTCP Template Install-Package FlexNet.Templates.SimpleTCP
ExpressionDelegate Builder Install-Package FlexNet.Builders.ExpressionDelegateBuilder

Usage

To get started, a Protocol has to be defined. This is done using the ProtocolBuilder. The below code creates a new ProtocolDefinition, using int as the IdType, and registers one Packet, SingleByteTransferPacket, with 0x00 as the ID.

ProtocolBuilder
    .Create<int>()
    .LengthBehaviour(new DefaultDynamicInt32LengthBehaviour())
    .UseIds(new DefaultIdHeader(), 
    new DelegateIdResolver((id, protocol) 
        => protocol.Packets.First(x => ((int)x.Id) == (int)id)))
    .RegisterDefaultAccessors()
    .RegisterPacket((packetBuilder) => packetBuilder
        .Id(0x00)
        .BindingType<SingleByteTransferPacket>()
        .BindField(nameof(SingleByteTransferPacket.Data))
    ).Build(new ExpressionDelegateBuilder());

For more information, check the Samples

API

To extend FlexNet, you can implement one of the following, depending on your needs:

Interface Defines Default Implementation
INetworkAccessor How a Type should be serialized. DefaultAccessors
ILengthBehaviour How Length should be serialized. This Folder
IIdHeader How an Id should be serialized. DefaultIdHeader
IIdMapper How Ids should be mapped to Packets DelegateIdMapper
IClient Client Functionality SimpleTCP Client
IServer Server Functionality. SimpleTCP Server
IDelegateBuilder How the read/write delegates are built. ExpressionDelegateBuilder

Building

To build this project, you will need to be able to run a Cake Build Script. Additionally, .NET Core 2.1 will be needed.

All unit tests target .NET Core 2.1, and FlexNet targets .NET Standard 2.0

Contributing

See the contributing file!

PRs are very welcome!

License

MIT © Kai Jellinghaus

About

A Networking Libary that is simple to use, but Flexible by Extensibility

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published