Code Monkey home page Code Monkey logo

nekoiolabs-tcp-communication's Introduction

NekoIOLabs-Tcp-Communication

General Info

This is a library I made so that people don't have to rewrite common TCP communication classes for server or client. This library has a genreal implementation of a TCP Server and client. Through the IProtocolParser Interface you are able to add any kind of protocol and get the parsed messages back from the library. As standard I'll release the library with Websocket support since there is no good websocket server provided for .net core outside of asp.net as far as i know. You also have the ILog

Features Progression

  • Bare TCP Communication
  • TLS Communication
  • UDP Communication
  • Raw TCP Protocol Parser
  • WebSocket Protocol Parser
  • Custom Protocol Parsers Through the IProtocolParser Interface
  • Custom Logging Interface
  • Multiple Unit tests

Basic Setup

It is realy simple to include this into your project. The only thing you need is to keep a var who hold the NekoIOLabsServer object and then plug in the parser you want for the server or keep the raw data.

1. Using the default parser and logger

//step one add the using statement atop;
using NekoIOLabsTcpCommunication.Server.Models;

//step two construct the server with a specific ip or any and a custom port of 8080 here
NekoIOLabsServer server = new NekoIOLabsServer(IPAddress.Any,NEKOIOLABS_COMMUNICATION_TYPE.TCP,8080);

//step three register to the two events that the server emit
server.OnMessageDecoded += Server_OnMessageDecoded;
server.OnClientStatusChanged += Server_OnClientStatusChanged;

//handle these events as you see fit
private static void Server_OnClientStatusChanged(NekoIOLabsTcpCommunication.Server.Events.ClientStateEventArgs args)
       {
          //handle client status you get the client id and a enum with the current status
       }

private static void Server_OnMessageDecoded(NekoIOLabsTcpCommunication.Server.Events.MessageParsedEventArgs eventargs)
       {
           //handle the decoded message you recieve from the protocol parser this will be an ICommand
           Console.WriteLine(eventargs.Client.ClientID + " recieved message " + eventargs.Command.ToString());
       }

// start the server it will automaticly run on a seperated thread
server.Start();

//to stop the server simply call
server.Stop();

Using Existing Parser

todo

Writing Custom Parser

todo

Using an Existing Logger

Writing a Custom logging

nekoiolabs-tcp-communication's People

Contributors

chelvaric avatar

Watchers

 avatar  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.