A Networking Libary that is simple to use, but Flexible by Extensibility
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 |
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
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 Id s should be mapped to Packet s |
DelegateIdMapper |
IClient | Client Functionality | SimpleTCP Client |
IServer | Server Functionality. | SimpleTCP Server |
IDelegateBuilder | How the read/write delegates are built. | ExpressionDelegateBuilder |
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
PRs are very welcome!