{"id":20734161,"url":"https://github.com/tmoonlight/litenetlib_mirror","last_synced_at":"2025-03-11T10:43:13.847Z","repository":{"id":105805075,"uuid":"225362296","full_name":"tmoonlight/LiteNetLib_Mirror","owner":"tmoonlight","description":null,"archived":false,"fork":false,"pushed_at":"2019-12-06T07:58:41.000Z","size":2859,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-18T00:49:11.638Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmoonlight.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://salt.bountysource.com/checkout/amount?team=litenetlib"]}},"created_at":"2019-12-02T11:45:52.000Z","updated_at":"2020-11-03T12:31:59.000Z","dependencies_parsed_at":"2023-06-14T01:46:11.439Z","dependency_job_id":null,"html_url":"https://github.com/tmoonlight/LiteNetLib_Mirror","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmoonlight%2FLiteNetLib_Mirror","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmoonlight%2FLiteNetLib_Mirror/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmoonlight%2FLiteNetLib_Mirror/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmoonlight%2FLiteNetLib_Mirror/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmoonlight","download_url":"https://codeload.github.com/tmoonlight/LiteNetLib_Mirror/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243020082,"owners_count":20222951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T05:28:58.476Z","updated_at":"2025-03-11T10:43:13.824Z","avatar_url":"https://github.com/tmoonlight.png","language":"C#","funding_links":["https://salt.bountysource.com/checkout/amount?team=litenetlib"],"categories":[],"sub_categories":[],"readme":"# LiteNetLib 0.9 indev\r\n\r\nLite reliable UDP library for .NET Framework 3.5, Mono, .NET Core 2.0, .NET Standard 2.0.\r\n\r\n[STABLE BRANCH (and examples) for 0.8.x](https://github.com/RevenantX/LiteNetLib/tree/0.8)\r\n\r\n[![Discord](https://img.shields.io/discord/501682175930925058.svg)](https://discord.gg/FATFPdy)\r\n\r\n[Little Game Example on Unity](https://github.com/RevenantX/NetGameExample)\r\n\r\n## Build\r\n\r\n### [NuGet](https://www.nuget.org/packages/LiteNetLib/) [![NuGet](https://img.shields.io/nuget/v/LiteNetLib.svg)](https://www.nuget.org/packages/LiteNetLib/) [![NuGet](https://img.shields.io/nuget/dt/LiteNetLib.svg)](https://www.nuget.org/packages/LiteNetLib/)\r\n\r\n### [Release builds](https://github.com/RevenantX/LiteNetLib/releases) [![GitHub (pre-)release](https://img.shields.io/github/release/RevenantX/LiteNetLib/all.svg)](https://github.com/RevenantX/LiteNetLib/releases)\r\n\r\n### [DLL build from master](https://ci.appveyor.com/project/RevenantX/litenetlib/branch/master/artifacts) [![](https://ci.appveyor.com/api/projects/status/354501wnvxs8kuh3/branch/master?svg=true)](https://ci.appveyor.com/project/RevenantX/litenetlib/branch/master)\r\n( Warning! Master branch can be unstable! )\r\n\r\n### Donations are welcome and will help further development of this project.\r\n[![Bountysource](https://img.shields.io/badge/bountysource-donate-green.svg)](https://salt.bountysource.com/checkout/amount?team=litenetlib)\r\n\r\n## Features\r\n\r\n* Lightweight\r\n  * Small CPU and RAM usage\r\n  * Small packet size overhead ( 1 byte for unreliable, 3 bytes for reliable packets )\r\n* Simple connection handling\r\n* Peer to peer connections\r\n* Helper classes for sending and reading messages\r\n* Multiple data channels\r\n* Different send mechanics\r\n  * Reliable with order\r\n  * Reliable without order\r\n  * Reliable sequenced (realiable only last packet)\r\n  * Ordered but unreliable with duplication prevention\r\n  * Simple UDP packets without order and reliability\r\n* Fast packet serializer [(Usage manual)](https://github.com/RevenantX/LiteNetLib/wiki/NetSerializer-usage)\r\n* Automatic small packets merging\r\n* Automatic fragmentation of reliable packets\r\n* Automatic MTU detection\r\n* UDP NAT hole punching\r\n* NTP time requests\r\n* Packet loss and latency simulation\r\n* IPv6 support (dual mode)\r\n* Connection statisitcs (need DEBUG or STATS_ENABLED flag)\r\n* Multicasting (for discovering hosts in local network)\r\n* Unity support\r\n* Supported platforms:\r\n  * Windows/Mac/Linux (.NET Framework, Mono, .NET Core)\r\n  * Android (Unity)\r\n  * iOS (Unity)\r\n  * UWP Windows 10 including phones\r\n  * Lumin OS (Magic Leap)\r\n\r\n## Unity notes!!!\r\n* Always use library sources instead of precompiled DLL files ( because there are platform specific #ifdefs and workarounds for unity bugs )\r\n\r\n## Usage samples\r\n\r\n### Client\r\n```csharp\r\nEventBasedNetListener listener = new EventBasedNetListener();\r\nNetManager client = new NetManager(listener);\r\nclient.Start();\r\nclient.Connect(\"localhost\" /* host ip or name */, 9050 /* port */, \"SomeConnectionKey\" /* text key or NetDataWriter */);\r\nlistener.NetworkReceiveEvent += (fromPeer, dataReader, deliveryMethod) =\u003e\r\n{\r\n    Console.WriteLine(\"We got: {0}\", dataReader.GetString(100 /* max length of string */));\r\n    dataReader.Recycle();\r\n};\r\n\r\nwhile (!Console.KeyAvailable)\r\n{\r\n    client.PollEvents();\r\n    Thread.Sleep(15);\r\n}\r\n\r\nclient.Stop();\r\n```\r\n### Server\r\n```csharp\r\nEventBasedNetListener listener = new EventBasedNetListener();\r\nNetManager server = new NetManager(listener);\r\nserver.Start(9050 /* port */);\r\n\r\nlistener.ConnectionRequestEvent += request =\u003e\r\n{\r\n    if(server.PeersCount \u003c 10 /* max connections */)\r\n        request.AcceptIfKey(\"SomeConnectionKey\");\r\n    else\r\n        request.Reject();\r\n};\r\n\r\nlistener.PeerConnectedEvent += peer =\u003e\r\n{\r\n    Console.WriteLine(\"We got connection: {0}\", peer.EndPoint); // Show peer ip\r\n    NetDataWriter writer = new NetDataWriter();                 // Create writer class\r\n    writer.Put(\"Hello client!\");                                // Put some string\r\n    peer.Send(writer, DeliveryMethod.ReliableOrdered);             // Send with reliability\r\n};\r\n\r\nwhile (!Console.KeyAvailable)\r\n{\r\n    server.PollEvents();\r\n    Thread.Sleep(15);\r\n}\r\nserver.Stop();\r\n```\r\n\r\n## NetManager settings description\r\n\r\n* **UnconnectedMessagesEnabled**\r\n  * enable messages receiving without connection. (with SendUnconnectedMessage method)\r\n  * default value: **false**\r\n* **NatPunchEnabled**\r\n  * enable NAT punch messages\r\n  * default value: **false**\r\n* **UpdateTime**\r\n  * library logic update (and send) period in milliseconds\r\n  * default value: **15 msec**.\r\n* **PingInterval**\r\n  * Interval for latency detection and checking connection\r\n  * default value: **1000 msec**.\r\n* **DisconnectTimeout**\r\n  * if client or server doesn't receive any packet from remote peer during this time then connection will be closed\r\n  * (including library internal keepalive packets)\r\n  * default value: **5000 msec**.\r\n* **SimulatePacketLoss**\r\n  * simulate packet loss by dropping random amout of packets. (Works only in DEBUG mode)\r\n  * default value: **false**\r\n* **SimulateLatency**\r\n  * simulate latency by holding packets for random time. (Works only in DEBUG mode)\r\n  * default value: **false**\r\n* **SimulationPacketLossChance**\r\n  * chance of packet loss when simulation enabled. value in percents.\r\n  * default value: **10 (%)**\r\n* **SimulationMinLatency**\r\n  * minimum simulated latency\r\n  * default value: **30 msec**\r\n* **SimulationMaxLatency**\r\n  * maximum simulated latency\r\n  * default value: **100 msec**\r\n* **BroadcastEnabled**\r\n  * Allows receive Broadcast packets\r\n  * default value: **false**\r\n* **ReconnectDelay**\r\n  * delay betwen connection attempts\r\n  * default value: **500 msec**\r\n* **MaxConnectAttempts**\r\n  * maximum connection attempts before client stops and call disconnect event.\r\n  * default value: **10**\r\n* **UnsyncedEvents**\r\n  * Experimental feature. Events automatically will be called without PollEvents method from another thread\r\n  * default value: **false**\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmoonlight%2Flitenetlib_mirror","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmoonlight%2Flitenetlib_mirror","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmoonlight%2Flitenetlib_mirror/lists"}