NTDLS.ReliableMessaging
1.10.15
See the version list below for details.
dotnet add package NTDLS.ReliableMessaging --version 1.10.15
NuGet\Install-Package NTDLS.ReliableMessaging -Version 1.10.15
<PackageReference Include="NTDLS.ReliableMessaging" Version="1.10.15" />
paket add NTDLS.ReliableMessaging --version 1.10.15
#r "nuget: NTDLS.ReliableMessaging, 1.10.15"
// Install NTDLS.ReliableMessaging as a Cake Addin #addin nuget:?package=NTDLS.ReliableMessaging&version=1.10.15 // Install NTDLS.ReliableMessaging as a Cake Tool #tool nuget:?package=NTDLS.ReliableMessaging&version=1.10.15
NTDLS.ReliableMessaging
📦 Be sure to check out the NuGet package: https://www.nuget.org/packages/NTDLS.ReliableMessaging
NTDLS.ReliableMessaging provides incredibly lightweight, simple, and high-performance TCP/IP based inter-process-communication / RPC functionality. This includes a server which listens for incoming connections and a client which makes a connection to the server.
Once connected, the server and the client can send fire-and-forget style notifications or dispatch queries which require a reply. All messages are handled by either convention or by events. Convention is achieved by adding a hander class with function signatures that match the message types which are being dispatched.
All messages are guaranteed to be received in their entirety and in the order in which they were dispatched.
CRC and compression are automatic and encryption is supported but optional.
Examples of sending messages and receiving them by convention:
Server:
Start a server and add a handler class.
static void Main()
{
var server = new RmServer();
server.AddHandler(new HandlerMethods());
server.Start(45784);
Console.WriteLine("Press [enter] to shutdown.");
Console.ReadLine();
server.Stop();
}
Client Example (Handlers by Convention):
Start a client, send a few notifications, a query and receive a query reply.
static void Main()
{
//Start a client and connect to the server.
var client = new RmClient();
client.Connect("localhost", 45784);
client.Notify(new MyNotification("This is message 001 from the client."));
client.Notify(new MyNotification("This is message 002 from the client."));
client.Notify(new MyNotification("This is message 003 from the client."));
//Send a query to the server, wait on a reply.
client.Query(new MyQuery("This is the query from the client.")).ContinueWith(x =>
{
//If we recevied a reply, print it to the console.
if (x.IsCompletedSuccessfully && x.Result != null)
{
Console.WriteLine($"Client received query reply: '{x.Result.Message}'");
}
else
{
Console.WriteLine($"Exception: '{x.Exception?.GetBaseException()?.Message}'");
}
});
Console.WriteLine("Press [enter] to shutdown.");
Console.ReadLine();
//Cleanup.
client.Disconnect();
}
Message handler Example:
Classes like this can be added to the server or the client to handle incomming notifications or queries.
internal class HandlerMethods : IReliableMessagingMessageHandler
{
public void MyNotificationReceived(ReliableMessagingContext context, MyNotification notification)
{
Console.WriteLine($"Server received notification: {notification.Message}");
}
public MyQueryReply MyQueryReceived(ReliableMessagingContext context, MyQuery query)
{
Console.WriteLine($"Server received query: '{query.Message}'");
return new MyQueryReply("This is the query reply from the server.");
}
}
Examples of sending messages and receiving them by events.
static void Main()
{
var server = new RmServer();
server.OnNotificationReceived += Server_OnNotificationReceived;
server.OnQueryReceived += Server_OnQueryReceived;
server.OnException += Server_OnException;
server.Start(45784);
Console.WriteLine("Press [enter] to shutdown.");
Console.ReadLine();
server.Stop();
}
private static IRmQueryReply Server_OnQueryReceived(RmContext context, IRmPayload payload)
{
if (payload is MyQuery myQuery)
{
Console.WriteLine($"Server received query: '{myQuery.Message}'");
return new MyQueryReply("This is the query reply from the server.");
}
else
{
throw new Exception("Payload type was not handled.");
}
}
private static void Server_OnNotificationReceived(RmContext context, IRmNotification payload)
{
if (payload is MyNotification myNotification)
{
Console.WriteLine($"Server received notification: {myNotification.Message}");
}
else
{
throw new Exception("Payload type was not handled.");
}
}
Payloads:
Classes that implement IReliableMessagingNotification are fire-and-forget type messages.
public class MyNotification : IReliableMessagingNotification
{
public string Message { get; set; }
public MyNotification(string message)
{
Message = message;
}
}
Classes that implement IReliableMessagingQuery are queries and they expect a reply, in this case the expected reply is in the type of MyQueryReply.
public class MyQuery : IReliableMessagingQuery<MyQueryReply>
{
public string Message { get; set; }
public MyQuery(string message)
{
Message = message;
}
}
Classes that implement IReliableMessagingQueryReply are replies from a dispatched query.
public class MyQueryReply : IReliableMessagingQueryReply
{
public string Message { get; set; }
public MyQueryReply(string message)
{
Message = message;
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Newtonsoft.Json (>= 13.0.3)
- NTDLS.Helpers (>= 1.3.7)
- NTDLS.Semaphore (>= 3.4.8)
- protobuf-net (>= 3.2.30)
-
net7.0
- Newtonsoft.Json (>= 13.0.3)
- NTDLS.Helpers (>= 1.3.7)
- NTDLS.Semaphore (>= 3.4.8)
- protobuf-net (>= 3.2.30)
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
- NTDLS.Helpers (>= 1.3.7)
- NTDLS.Semaphore (>= 3.4.8)
- protobuf-net (>= 3.2.30)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on NTDLS.ReliableMessaging:
Package | Downloads |
---|---|
NTDLS.MemoryQueue
An in-memory, non-persistent message queue designed for efficient inter-process communication, task queuing, load balancing, and data buffering over TCP/IP |
|
NTDLS.Katzebase.Api
Client for Katzebase document-based database engine for Windows and Linux. |
|
NTDLS.Katzebase.Client.dev
Client for Katzebase document-based database engine for Windows and Linux. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.11.1 | 43 | 12/26/2024 |
1.11.0 | 120 | 12/21/2024 |
1.10.18 | 123 | 12/3/2024 |
1.10.17 | 82 | 12/3/2024 |
1.10.16 | 93 | 10/22/2024 |
1.10.15 | 84 | 10/22/2024 |
1.10.14 | 84 | 10/22/2024 |
1.10.13 | 84 | 10/22/2024 |
1.10.12 | 92 | 10/13/2024 |
1.10.11 | 90 | 10/13/2024 |
1.10.10 | 95 | 10/13/2024 |
1.10.9 | 669 | 8/28/2024 |
1.10.8 | 214 | 8/25/2024 |
1.10.7 | 158 | 8/24/2024 |
1.10.6 | 151 | 8/20/2024 |
1.10.5 | 138 | 8/20/2024 |
1.10.4 | 149 | 8/13/2024 |
1.10.3 | 111 | 8/13/2024 |
1.10.2 | 134 | 8/13/2024 |
1.10.1 | 117 | 8/13/2024 |
1.10.0 | 143 | 8/12/2024 |
1.9.3 | 243 | 8/7/2024 |
1.9.2 | 90 | 8/7/2024 |
1.9.1 | 104 | 8/5/2024 |
1.9.0 | 68 | 8/5/2024 |
1.8.8 | 72 | 8/3/2024 |
1.8.7 | 87 | 8/1/2024 |
1.8.6 | 204 | 6/26/2024 |
1.8.5 | 109 | 6/20/2024 |
1.8.4 | 109 | 6/19/2024 |
1.8.3 | 114 | 6/19/2024 |
1.8.2 | 109 | 6/11/2024 |
1.8.1 | 91 | 6/11/2024 |
1.8.0 | 106 | 6/10/2024 |
1.7.6 | 109 | 6/8/2024 |
1.7.5 | 118 | 6/8/2024 |
1.7.4 | 102 | 6/8/2024 |
1.7.3 | 121 | 6/7/2024 |
1.7.2 | 109 | 6/7/2024 |
1.7.1 | 117 | 6/7/2024 |
1.7.0 | 102 | 6/7/2024 |
1.6.2 | 121 | 6/6/2024 |
1.6.1 | 114 | 6/6/2024 |
1.6.0 | 114 | 6/6/2024 |
1.5.5 | 112 | 6/6/2024 |
1.5.4 | 108 | 6/6/2024 |
1.5.3 | 113 | 6/6/2024 |
1.5.2 | 119 | 6/5/2024 |
1.5.1 | 135 | 5/3/2024 |
1.5.0 | 101 | 5/2/2024 |
1.4.1 | 149 | 2/19/2024 |
1.4.0 | 216 | 2/15/2024 |
1.3.11 | 471 | 2/1/2024 |
1.3.10 | 300 | 1/31/2024 |
1.3.9 | 128 | 1/22/2024 |
1.3.8 | 112 | 1/22/2024 |
1.3.7 | 142 | 1/4/2024 |
1.3.6 | 140 | 12/29/2023 |
1.3.5 | 119 | 12/27/2023 |
1.3.4 | 134 | 12/27/2023 |
1.3.3 | 144 | 12/22/2023 |
1.3.2 | 118 | 12/21/2023 |
1.3.1 | 118 | 12/21/2023 |
1.3.0 | 121 | 12/21/2023 |
1.2.4 | 130 | 12/19/2023 |
1.2.3 | 132 | 12/18/2023 |
1.2.2 | 183 | 11/15/2023 |
1.2.1 | 133 | 11/10/2023 |
1.2.0 | 137 | 11/7/2023 |
1.1.0 | 121 | 11/7/2023 |
1.0.1 | 131 | 11/7/2023 |
1.0.0 | 134 | 11/6/2023 |
Dependency updates.