{"id":13711473,"url":"https://github.com/Toemsel/Network","last_synced_at":"2025-05-06T20:33:04.305Z","repository":{"id":43026517,"uuid":"74980480","full_name":"Toemsel/Network","owner":"Toemsel","description":"C# Network Library","archived":false,"fork":false,"pushed_at":"2024-02-12T00:42:43.000Z","size":4305,"stargazers_count":357,"open_issues_count":12,"forks_count":65,"subscribers_count":21,"default_branch":"main","last_synced_at":"2024-11-12T22:35:39.911Z","etag":null,"topics":["async","bluetooth","encryption-decryption","network","rsa","tcp","udp","xamarin"],"latest_commit_sha":null,"homepage":"https://push-force.dev","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Toemsel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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}},"created_at":"2016-11-28T14:24:09.000Z","updated_at":"2024-11-09T13:55:49.000Z","dependencies_parsed_at":"2024-05-13T00:44:46.717Z","dependency_job_id":null,"html_url":"https://github.com/Toemsel/Network","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Toemsel%2FNetwork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Toemsel%2FNetwork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Toemsel%2FNetwork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Toemsel%2FNetwork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Toemsel","download_url":"https://codeload.github.com/Toemsel/Network/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224528415,"owners_count":17326361,"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":["async","bluetooth","encryption-decryption","network","rsa","tcp","udp","xamarin"],"created_at":"2024-08-02T23:01:08.636Z","updated_at":"2024-11-13T21:31:53.309Z","avatar_url":"https://github.com/Toemsel.png","language":"C#","funding_links":["https://www.buymeacoffee.com/yoghurt"],"categories":["Networks"],"sub_categories":[],"readme":"# C# Network Library\n\n[![forthebadge](https://forthebadge.com/images/badges/as-seen-on-tv.svg)](https://forthebadge.com)\n[![forthebadge](https://forthebadge.com/images/badges/contains-cat-gifs.svg)](https://forthebadge.com)\n\nLicence https://www.gnu.org/licenses/lgpl-3.0.en.html \u003cbr /\u003e\nNuGet https://www.nuget.org/packages/Network/ \u003cbr /\u003e\nChat: https://discordapp.com/invite/tgAzGby \u003cbr /\u003e\nWebsite: https://www.push-force.dev/\n\n# Continuous Integration\n\n| Build | Architecture | Framework Target | Badge |\n| ------------------- | ------------ | ---------------- | ----- |\n| Debug | x86 | standard2.0 | [![Build status](https://thomaschristof.visualstudio.com/Network/_apis/build/status/DEBUG%20%20.NET%20Standard%202.0)](https://thomaschristof.visualstudio.com/Network/_build/latest?definitionId=12) |\n| Release | x86 | standard2.0 | [![Build status](https://thomaschristof.visualstudio.com/Network/_apis/build/status/RELEASE%20.NET%20Standard%202.0)](https://thomaschristof.visualstudio.com/Network/_build/latest?definitionId=9) |\n\n# Badges\n\n| Service | Description | Badge |\n| ------- | ----------- | ----- |\n| CodeFactor | Code Quality | ![CodeFactor](https://www.codefactor.io/repository/github/toemsel/network/badge) |\n| NuGet | Download Count | ![NuGet](https://img.shields.io/nuget/dt/Network.svg) |\n| NuGet | Current Version | ![NuGet](https://img.shields.io/nuget/v/Network.svg) |\n| Discord | Chat-Room | [![Discord](https://img.shields.io/discord/502989126916898837.svg)](https://discord.gg/tgAzGby) |\n\n# Support\n\n[Buy me a coffee ☕](https://www.buymeacoffee.com/yoghurt)\n\n# Supported Frameworks\n\n- .NET Standard           \u003e= 2.0\n- .NET Core               \u003e= 2.0\n- .NET Framework          \u003e= 5.0\n- .NET Framework          \u003e= 4.6.1\n- Mono                    \u003e= 5.4\n- Xamarin.iOS             \u003e= 10.14\n- Xamarin.MAC             \u003e= 3.8\n- Xamarin.Android         \u003e= 8.0\n- UWP                     \u003e= 10.0.16299\n- Unity                   \u003e= 2018.1\n\n# Features in a nutshell\n\n- TCP communication\n- UDP communication\n- Factories to ensure the most easy setup\n- Server and Client Wrappers (Auto-Reconnect, Auto-Join)\n- Object oriented. Don't worry about bits and bytes. **Send and receive objects**\n- Optional RSA encryption for TCP and UDP\n- Use lambdas, delegates or even async operations to send and receive objects\n- Useful helpers to quickly send small information, without creating an object\n- Logging for debugging or traffic inspection\n- No magic numbers, identifiers or configurations required\n- Very fast and relieable (6-10ms RTT)\n- Highly customizable\n- OpenSource and Free to use\n\n# Example Client\n```c#\n        public void Demo()\n        {\n            ConnectionResult connectionResult = ConnectionResult.TCPConnectionNotAlive;\n            //1. Establish a connection to the server.\n            TcpConnection tcpConnection = ConnectionFactory.CreateTcpConnection(\"127.0.0.1\", 1234, out connectionResult);\n            //2. Register what happens if we get a connection\n            if(connectionResult == ConnectionResult.Connected)\n            {\n                Console.WriteLine($\"{tcpConnection.ToString()} Connection established\");\n                //3. Send a raw data packet request.\n                tcpConnection.SendRawData(RawDataConverter.FromUTF8String(\"HelloWorld\", \"Hello, this is the RawDataExample!\"));\n                tcpConnection.SendRawData(RawDataConverter.FromBoolean(\"BoolValue\", true));\n                tcpConnection.SendRawData(RawDataConverter.FromBoolean(\"BoolValue\", false));\n                tcpConnection.SendRawData(RawDataConverter.FromDouble(\"DoubleValue\", 32.99311325d));\n                //4. Send a raw data packet request without any helper class\n                tcpConnection.SendRawData(\"HelloWorld\", Encoding.UTF8.GetBytes(\"Hello, this is the RawDataExample!\"));\n                tcpConnection.SendRawData(\"BoolValue\", BitConverter.GetBytes(true));\n                tcpConnection.SendRawData(\"BoolValue\", BitConverter.GetBytes(false));\n                tcpConnection.SendRawData(\"DoubleValue\", BitConverter.GetBytes(32.99311325d));\n            }\n        }\n```\n\n# Example Server\n```c#\n        public void Demo()\n        {\n            //1. Start listen on a port\n            serverConnectionContainer = ConnectionFactory.CreateServerConnectionContainer(1234, false);\n\n            //2. Apply optional settings.\n            #region Optional settings\n            serverConnectionContainer.ConnectionLost += (a, b, c) =\u003e Console.WriteLine($\"{serverConnectionContainer.Count} {b.ToString()} Connection lost {a.IPRemoteEndPoint.Port}. Reason {c.ToString()}\");\n            serverConnectionContainer.ConnectionEstablished += connectionEstablished;\n            serverConnectionContainer.AllowUDPConnections = true;\n            serverConnectionContainer.UDPConnectionLimit = 2;\n            #endregion Optional settings\n\n            //Call start here, because we had to enable the bluetooth property at first.\n            serverConnectionContainer.Start();\n        }\n\n        /// \u003csummary\u003e\n        /// We got a connection.\n        /// \u003c/summary\u003e\n        /// \u003cparam name=\"connection\"\u003eThe connection we got. (TCP or UDP)\u003c/param\u003e\n        private void connectionEstablished(Connection connection, ConnectionType type)\n        {\n            Console.WriteLine($\"{serverConnectionContainer.Count} {connection.GetType()} connected on port {connection.IPRemoteEndPoint.Port}\");\n\n            //3. Register packet listeners.\n            connection.RegisterRawDataHandler(\"HelloWorld\", (rawData, con) =\u003e Console.WriteLine($\"RawDataPacket received. Data: {rawData.ToUTF8String()}\"));\n            connection.RegisterRawDataHandler(\"BoolValue\", (rawData, con) =\u003e Console.WriteLine($\"RawDataPacket received. Data: {rawData.ToBoolean()}\"));\n            connection.RegisterRawDataHandler(\"DoubleValue\", (rawData, con) =\u003e Console.WriteLine($\"RawDataPacket received. Data: {rawData.ToDouble()}\"));\n        }\n```\n\n# Async Example\n```c#\n        public async void Demo()\n        {\n            //1. Establish a connection to the server.\n            ClientConnectionContainer container = ConnectionFactory.CreateClientConnectionContainer(\"127.0.0.1\", 1234);\n            //2. Register what happens if we get a connection\n            container.ConnectionEstablished += async (connection, type) =\u003e\n            {\n                Console.WriteLine($\"{type.ToString()} Connection established\");\n                //3. Send a request packet async and directly receive an answer.\n                CalculationResponse response = await connection.SendAsync\u003cCalculationResponse\u003e(new CalculationRequest(10, 10));\n                Console.WriteLine($\"Answer received {response.Result}\");\n            };\n        }\n```\n\n# Delegate Example\n```c#\n        private ClientConnectionContainer container;\n\n        public void Demo()\n        {\n            //1. Establish a connection to the server.\n            container = ConnectionFactory.CreateClientConnectionContainer(\"127.0.0.1\", 1234);\n            //2. Register what happens if we get a connection\n            container.ConnectionEstablished += connectionEstablished;\n        }\n\n        private void connectionEstablished(Connection connection, ConnectionType type)\n        {\n            Console.WriteLine($\"{type.ToString()} Connection established\");\n            //3. Register what happens if we receive a packet of type \"CalculationResponse\"\n            container.RegisterPacketHandler\u003cCalculationResponse\u003e(calculationResponseReceived, this);\n            //4. Send a calculation request.\n            connection.Send(new CalculationRequest(10, 10), this);\n        }\n\n        private void calculationResponseReceived(CalculationResponse response, Connection connection)\n        {\n            //5. CalculationResponse received.\n            Console.WriteLine($\"Answer received {response.Result}\");\n        }\n ```\n \n# Lambda Example\n ```c#\n         public void Demo()\n        {\n            //1. Establish a connection to the server.\n            ClientConnectionContainer container = ConnectionFactory.CreateClientConnectionContainer(\"127.0.0.1\", 1234);\n            //2. Register what happens if we get a connection\n            container.ConnectionEstablished += (connection, type) =\u003e\n            {\n                Console.WriteLine($\"{type.ToString()} Connection established\");\n                //3. Register what happens if we receive a packet of type \"CalculationResponse\"\n                connection.RegisterPacketHandler\u003cCalculationResponse\u003e((response, con) =\u003e Console.WriteLine($\"Answer received {response.Result}\"), this);\n                //4. Send a calculation request.\n                connection.Send(new CalculationRequest(10, 10), this);\n            };\n        }\n ```\n   \n# RSA Example\n   ```c#\n        public async void Demo()\n        {\n            //1. Establish a connection.\n            ClientConnectionContainer container = ConnectionFactory.CreateSecureClientConnectionContainer(\"127.0.0.1\", 1234);\n            //2. Register what happens if we get a connection\n            container.ConnectionEstablished += (connection, type) =\u003e\n            {\n                Console.WriteLine($\"{type.ToString()} Connection established\");\n                //3. Register what happens if we receive a packet of type \"CalculationResponse\"\n                connection.RegisterPacketHandler\u003cCalculationResponse\u003e((response, con) =\u003e Console.WriteLine($\"Answer received {response.Result}\"), this);\n                //4. Send a calculation request.\n                connection.Send(new CalculationRequest(10, 10), this);\n            };\n        }\n   ```\n\n# Logging\n\n\u003cimg src=\"https://www.push-force.dev/resource/Logging.gif\" /\u003e\n\n# Logging with RSA\n\n\u003cimg src=\"https://www.push-force.dev/resource/RSA.gif\" /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FToemsel%2FNetwork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FToemsel%2FNetwork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FToemsel%2FNetwork/lists"}