![forthebadge](https://camo.githubusercontent.com/16480beeea45d9feee1515e4ac919043199b0dac9056ddc9ea90a734d0a4b9e3/68747470733a2f2f666f7274686562616467652e636f6d2f696d616765732f6261646765732f636f6e7461696e732d6361742d676966732e737667)
Tutorials https://www.indie-dev.at/overview-en/
Downloads http://www.indie-dev.at/?page_id=480
Licence http://www.indie-dev.at/?page_id=525
Documentation http://www.indie-dev.at/?page_id=476
NuGet https://www.nuget.org/packages/Network/
Chat: https://discordapp.com/invite/tgAzGby
Build |
Architecture |
Framework Target |
Badge |
Debug |
x86 |
standard2.0 |
![Build status](https://camo.githubusercontent.com/8eaef2f7dc759d2a29169b0441ae5833d4205c4dc397f7b10f3432ade6394850/68747470733a2f2f74686f6d61736368726973746f662e76697375616c73747564696f2e636f6d2f4e6574776f726b2f5f617069732f6275696c642f7374617475732f44454255472532302532302e4e45542532305374616e64617264253230322e30) |
Release |
x86 |
standard2.0 |
![Build status](https://camo.githubusercontent.com/9cb51e854da28d1af438cecb06032f6539acd25e3cf4d4a318f5c9c5baba6602/68747470733a2f2f74686f6d61736368726973746f662e76697375616c73747564696f2e636f6d2f4e6574776f726b2f5f617069732f6275696c642f7374617475732f52454c454153452532302e4e45542532305374616e64617264253230322e30) |
Service |
Description |
Badge |
CodeFactor |
Code Quality |
![CodeFactor](https://camo.githubusercontent.com/a30ae7c17c1d634147c6d5615085b7e78b789a4651b2ecfc8656465e222d2fd4/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f746f656d73656c2f6e6574776f726b2f6261646765) |
NuGet |
Download Count |
![NuGet](https://camo.githubusercontent.com/fefd1155dc233ad0bb861b4cf789e536f27d7d8e0e73239505b56a5ce1b60e28/68747470733a2f2f696d672e736869656c64732e696f2f6e756765742f64742f4e6574776f726b2e737667) |
NuGet |
Current Version |
![NuGet](https://camo.githubusercontent.com/aad0ecd8a3ac6be61a3d28458f73b5257d559052799249d99c223efeac283661/68747470733a2f2f696d672e736869656c64732e696f2f6e756765742f762f4e6574776f726b2e737667) |
Discord |
Chat-Room |
![Discord](https://camo.githubusercontent.com/e7115fe3063fa8a7efd4921b4202cf756b66c9b45242cb1b7349074e591f899b/68747470733a2f2f696d672e736869656c64732e696f2f646973636f72642f3530323938393132363931363839383833372e737667) |
Buy me a coffee ☕
- .NET Standard >= 2.0
- .NET Core >= 2.0
- .NET Framework >= 5.0
- .NET Framework >= 4.6.1
- Mono >= 5.4
- Xamarin.iOS >= 10.14
- Xamarin.MAC >= 3.8
- Xamarin.Android >= 8.0
- UWP >= 10.0.16299
- Unity >= 2018.1
- TCP communication
- UDP communication
- Factories to ensure the most easy setup
- Server and Client Wrappers (Auto-Reconnect, Auto-Join)
- Object oriented. Don't worry about bits and bytes. Send and receive objects
- Optional RSA encryption for TCP and UDP
- Use lambdas, delegates or even async operations to send and receive objects
- Useful helpers to quickly send small information, without creating an object
- Logging for debugging or traffic inspection
- No magic numbers, identifiers or configurations required
- Very fast and relieable (6-10ms RTT)
- Highly customizable
- OpenSource and Free to use
public void Demo()
{
ConnectionResult connectionResult = ConnectionResult.TCPConnectionNotAlive;
//1. Establish a connection to the server.
TcpConnection tcpConnection = ConnectionFactory.CreateTcpConnection("127.0.0.1", 1234, out connectionResult);
//2. Register what happens if we get a connection
if(connectionResult == ConnectionResult.Connected)
{
Console.WriteLine($"{tcpConnection.ToString()} Connection established");
//3. Send a raw data packet request.
tcpConnection.SendRawData(RawDataConverter.FromUTF8String("HelloWorld", "Hello, this is the RawDataExample!"));
tcpConnection.SendRawData(RawDataConverter.FromBoolean("BoolValue", true));
tcpConnection.SendRawData(RawDataConverter.FromBoolean("BoolValue", false));
tcpConnection.SendRawData(RawDataConverter.FromDouble("DoubleValue", 32.99311325d));
//4. Send a raw data packet request without any helper class
tcpConnection.SendRawData("HelloWorld", Encoding.UTF8.GetBytes("Hello, this is the RawDataExample!"));
tcpConnection.SendRawData("BoolValue", BitConverter.GetBytes(true));
tcpConnection.SendRawData("BoolValue", BitConverter.GetBytes(false));
tcpConnection.SendRawData("DoubleValue", BitConverter.GetBytes(32.99311325d));
}
}
public void Demo()
{
//1. Start listen on a port
serverConnectionContainer = ConnectionFactory.CreateServerConnectionContainer(1234, false);
//2. Apply optional settings.
#region Optional settings
serverConnectionContainer.ConnectionLost += (a, b, c) => Console.WriteLine($"{serverConnectionContainer.Count} {b.ToString()} Connection lost {a.IPRemoteEndPoint.Port}. Reason {c.ToString()}");
serverConnectionContainer.ConnectionEstablished += connectionEstablished;
serverConnectionContainer.AllowUDPConnections = true;
serverConnectionContainer.UDPConnectionLimit = 2;
#endregion Optional settings
//Call start here, because we had to enable the bluetooth property at first.
serverConnectionContainer.Start();
}
/// <summary>
/// We got a connection.
/// </summary>
/// <param name="connection">The connection we got. (TCP or UDP)</param>
private void connectionEstablished(Connection connection, ConnectionType type)
{
Console.WriteLine($"{serverConnectionContainer.Count} {connection.GetType()} connected on port {connection.IPRemoteEndPoint.Port}");
//3. Register packet listeners.
connection.RegisterRawDataHandler("HelloWorld", (rawData, con) => Console.WriteLine($"RawDataPacket received. Data: {rawData.ToUTF8String()}"));
connection.RegisterRawDataHandler("BoolValue", (rawData, con) => Console.WriteLine($"RawDataPacket received. Data: {rawData.ToBoolean()}"));
connection.RegisterRawDataHandler("DoubleValue", (rawData, con) => Console.WriteLine($"RawDataPacket received. Data: {rawData.ToDouble()}"));
}
![](https://camo.githubusercontent.com/a9349a05b5d9564abe6cfd4a53def4a7733fc7be82582f1e4897102e97f9c8d1/687474703a2f2f7777772e696e6469652d6465762e61742f77702d636f6e74656e742f75706c6f6164732f323031362f31312f44656d6f2e676966)
public async void Demo()
{
//1. Establish a connection to the server.
ClientConnectionContainer container = ConnectionFactory.CreateClientConnectionContainer("127.0.0.1", 1234);
//2. Register what happens if we get a connection
container.ConnectionEstablished += async (connection, type) =>
{
Console.WriteLine($"{type.ToString()} Connection established");
//3. Send a request packet async and directly receive an answer.
CalculationResponse response = await connection.SendAsync<CalculationResponse>(new CalculationRequest(10, 10));
Console.WriteLine($"Answer received {response.Result}");
};
}
private ClientConnectionContainer container;
public void Demo()
{
//1. Establish a connection to the server.
container = ConnectionFactory.CreateClientConnectionContainer("127.0.0.1", 1234);
//2. Register what happens if we get a connection
container.ConnectionEstablished += connectionEstablished;
}
private void connectionEstablished(Connection connection, ConnectionType type)
{
Console.WriteLine($"{type.ToString()} Connection established");
//3. Register what happens if we receive a packet of type "CalculationResponse"
container.RegisterPacketHandler<CalculationResponse>(calculationResponseReceived, this);
//4. Send a calculation request.
connection.Send(new CalculationRequest(10, 10), this);
}
private void calculationResponseReceived(CalculationResponse response, Connection connection)
{
//5. CalculationResponse received.
Console.WriteLine($"Answer received {response.Result}");
}
public void Demo()
{
//1. Establish a connection to the server.
ClientConnectionContainer container = ConnectionFactory.CreateClientConnectionContainer("127.0.0.1", 1234);
//2. Register what happens if we get a connection
container.ConnectionEstablished += (connection, type) =>
{
Console.WriteLine($"{type.ToString()} Connection established");
//3. Register what happens if we receive a packet of type "CalculationResponse"
connection.RegisterPacketHandler<CalculationResponse>((response, con) => Console.WriteLine($"Answer received {response.Result}"), this);
//4. Send a calculation request.
connection.Send(new CalculationRequest(10, 10), this);
};
}
public async void Demo()
{
//1. Establish a connection.
ClientConnectionContainer container = ConnectionFactory.CreateSecureClientConnectionContainer("127.0.0.1", 1234);
//2. Register what happens if we get a connection
container.ConnectionEstablished += (connection, type) =>
{
Console.WriteLine($"{type.ToString()} Connection established");
//3. Register what happens if we receive a packet of type "CalculationResponse"
connection.RegisterPacketHandler<CalculationResponse>((response, con) => Console.WriteLine($"Answer received {response.Result}"), this);
//4. Send a calculation request.
connection.Send(new CalculationRequest(10, 10), this);
};
}
![](https://camo.githubusercontent.com/dd702df026e0f1cabb38ca1ec61355f2a4b147f28acda41f701151ac0fd114fa/687474703a2f2f7777772e696e6469652d6465762e61742f77702d636f6e74656e742f75706c6f6164732f323031362f31312f4c6f6767696e672e676966)
![](https://camo.githubusercontent.com/4a2f4f2eeffeee774a0f4b705c047949ea896a62327b24fec3baed82e07b47f0/68747470733a2f2f7777772e696e6469652d6465762e61742f77702d636f6e74656e742f75706c6f6164732f323031382f30382f5253412e676966)