Giter Site home page Giter Site logo

freedomwind / litenetlib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from revenantx/litenetlib

0.0 0.0 0.0 5.97 MB

Lite reliable UDP library for Mono and .NET

Home Page: https://revenantx.github.io/LiteNetLib/index.html

License: MIT License

C# 99.99% Batchfile 0.01%

litenetlib's Introduction

LiteNetLib 1.0 indev

Lite reliable UDP library for .NET Standard 2.0 (Mono, .NET Core, .NET Framework)

Made in Ukraine

"Buy Me A Coffee"

BTC:bc1qn3lwhafsp7ka0r5lew0v7r3qnpj62atqju809n

LTC:LTQqo9yjGVWrXahAByqvx9Jo5TaotjDKXJ

ETH:0x78664986894932bD399B1539D9F65155D0BF55bd

Discord chat: Discord

OLD BRANCH (and examples) for 0.9.x

Little Game Example on Unity

Documentation

Build

( Warning! Master branch can be unstable! )

Features

  • Lightweight
    • Small CPU and RAM usage
    • Small packet size overhead ( 1 byte for unreliable, 4 bytes for reliable packets )
  • Simple connection handling
  • Peer to peer connections
  • Helper classes for sending and reading messages
  • Multiple data channels
  • Different send mechanics
    • Reliable with order
    • Reliable without order
    • Reliable sequenced (realiable only last packet)
    • Ordered but unreliable with duplication prevention
    • Simple UDP packets without order and reliability
  • Fast packet serializer (Usage manual)
  • Automatic small packets merging
  • Automatic fragmentation of reliable packets
  • Automatic MTU detection
  • Optional CRC32C checksums
  • UDP NAT hole punching
  • NTP time requests
  • Packet loss and latency simulation
  • IPv6 support (dual mode)
  • Connection statisitcs
  • Multicasting (for discovering hosts in local network)
  • Unity support
  • Supported platforms:
    • Windows/Mac/Linux (.NET Framework, Mono, .NET Core, .NET Standard)
    • Lumin OS (Magic Leap)
    • Monogame
    • Godot
    • Unity 2018.3 (Desktop platforms, Android, iOS, Switch)

Unity notes!!!

  • Minimal supported Unity is 2018.3. For older Unity versions use 0.9.x library versions
  • Always use library sources instead of precompiled DLL files ( because there are platform specific #ifdefs and workarounds for unity bugs )

Usage samples

Client

EventBasedNetListener listener = new EventBasedNetListener();
NetManager client = new NetManager(listener);
client.Start();
client.Connect("localhost" /* host ip or name */, 9050 /* port */, "SomeConnectionKey" /* text key or NetDataWriter */);
listener.NetworkReceiveEvent += (fromPeer, dataReader, deliveryMethod) =>
{
    Console.WriteLine("We got: {0}", dataReader.GetString(100 /* max length of string */));
    dataReader.Recycle();
};

while (!Console.KeyAvailable)
{
    client.PollEvents();
    Thread.Sleep(15);
}

client.Stop();

Server

EventBasedNetListener listener = new EventBasedNetListener();
NetManager server = new NetManager(listener);
server.Start(9050 /* port */);

listener.ConnectionRequestEvent += request =>
{
    if(server.ConnectedPeersCount < 10 /* max connections */)
        request.AcceptIfKey("SomeConnectionKey");
    else
        request.Reject();
};

listener.PeerConnectedEvent += peer =>
{
    Console.WriteLine("We got connection: {0}", peer.EndPoint); // Show peer ip
    NetDataWriter writer = new NetDataWriter();                 // Create writer class
    writer.Put("Hello client!");                                // Put some string
    peer.Send(writer, DeliveryMethod.ReliableOrdered);             // Send with reliability
};

while (!Console.KeyAvailable)
{
    server.PollEvents();
    Thread.Sleep(15);
}
server.Stop();

litenetlib's People

Contributors

alexr1221 avatar alexstormwood avatar alexthealmighty avatar ashoulson avatar chrisnobrega avatar cyberandrii avatar forestrf avatar frooxius avatar hguehfuwie avatar hyabean avatar jasperciti avatar jblai avatar jounim avatar kaladrius2trip avatar marsermd avatar mewiof avatar michalpetryka avatar moe-baker avatar momo-the-monster avatar nventimiglia avatar pnarimani avatar revenantx avatar saishy avatar sasvdw avatar sewer56 avatar tomzorz avatar trevordaschoculus avatar ubiguchi avatar xmedeko avatar yacuzo 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.