Giter Club home page Giter Club logo

netly's Introduction

powered by ALEC1O

About

Netly is a open source socket library for c# (C-Sharp). It facilitates the use of socket (UDP and TCP, Client and Server) with which it is compatible (Android, iOS, macOS, Linux, Windows, ...) as long as it is compiled with its destination.


Docs

See the documentation here!


Install

Official publisher
Nuget Unity Asset Store
Install on Nuget Install on Asset Store

Versions

Notable changes
v1 (old) v2 (current) v3 (nonexistent)
TCP client/server TCP/IP Message Framing SSL client/server
UDP client/server TCP/UDP performance improvement Add documentation and samples for SSL

Dependency


Build

  • Build dependencies

  • Build step-by-step

# 1. clone repository 
$ git clone "https://github.com/alec1o/netly.git"

# 2. open source directory 
$ cd netly/

# 5. restore dotnet project
$ dotnet restore

# 6. build dotnet project
$ dotnet build

List of tested platforms


Demo

  • Client

    Instance
    using Netly;
    using Netly.Core;
    
    // Example udp client instance
    var client = new UdpClient();
    
    // Example tcp client instance
    var client = new TcpClient();
    
    // Example host instance
    var host = new Host("127.0.0.1", 3000);    
    Usage
    client.OnOpen(() =>
    {
        // connection opened
    });
    
    client.OnClose(() =>
    {
        // connection closed
    });
    
    client.OnError((exception) =>
    {   
        // error on open connection
    });
    
    client.OnData((data) => 
    {
        // buffer/data received
    });
    
    client.OnEvent((name, data) =>
    {
        // event received: {name: event name} {data: buffer/data received} 
    });
    
    // open connection
    client.Open(host);
    
    // send data
    client.ToData(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9});
    
    // send event
    client.ToEvent("name", new byte[] { 1, 2, 3, 4, 5, 6});
    
    // close connection
    client.Close();
  • Server

    Instance
    using Netly;
    using Netly.Core;
    
    // Example tcp server instance
    var server = new TcpServer();
    
    // Example udp server instance
    var server = new UdpServer();
    
    // Example host instance
    var host = new Host("0.0.0.0", 3000);
    Usage
    server.OnOpen(() =>
    {
        // connection opened: server start listen client
    });
    
    server.OnClose(() =>
    {
        // connection closed: server stop listen client
    });
    
    server.OnError((exception) =>
    {
        // error on open connection
    });
    
    server.OnEnter((client) =>
    {
        // client connected: connection accepted
    });
    
    server.OnExit((client) =>
    {
        // client disconnected: connection closed
    });
    
    server.OnData((client, data) =>
    {
        // buffer/data received: {client: client instance} {data: buffer/data received} 
    });
    
    server.OnEvent((client, name, data) =>
    {
        // event received: {client: client instance} {name: event name} {data: buffer received} 
    });
    
    // open connection
    server.Open(host);
    
    // broadcast data to clients
    server.ToData(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9});
    
    // broadcast event to clients
    server.ToEvent("name", new byte[] { 1, 2, 3, 4, 5, 6});
    
    // close connection
    server.Close();

Currently missing feature

Below are some missing features that are planned to be added in later versions.

  • [SslClient and SslServer] Tcp protocol with SSL/TLS encryption.

netly's People

Contributors

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