Git Product home page Git Product logo

flexnet's Introduction

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

flexnet's People

Contributors

hurricankai avatar

Stargazers

mari avatar Coding Seb avatar etheaven avatar Lukas Möller avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.