MyNatsClient 0.14.1

Provides a simple, effective sync and async library for interacting with NATS Server using .NET and .NET Core. It uses IObservable so it is ReactiveX (RX) friendly.

Install-Package MyNatsClient -Version 0.14.1
dotnet add package MyNatsClient --version 0.14.1
<PackageReference Include="MyNatsClient" Version="0.14.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MyNatsClient --version 0.14.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Pub-Sub sample

Simple pub-sub sample showing one client that publishes and one that subscribes. This can of course be the same client and you can also have more clients subscribing etc.

Publisher

var cnInfo = new ConnectionInfo("192.168.1.10");
var client = new NatsClient(cnInfo);

await client.ConnectAsync();

await client.PubAsync("tick", GetNextTick());

//or using an encoding package e.g. Json
await client.PubAsJsonAsync("tickItem", new Tick { Value = GetNextTick() });

Subscriber

var cnInfo = new ConnectionInfo("192.168.1.10");
var client = new NatsClient(cnInfo);

await _client.ConnectAsync();

await client.SubAsync("tick", stream => stream.Subscribe(msg => {
    Console.WriteLine($"Clock ticked. Tick is {msg.GetPayloadAsString()}");
}));

//or using an encoding package e.g Json
await client.SubAsync("tickItem", stream => stream.Subscribe(msg => {
    Console.WriteLine($"Clock ticked. Tick is {msg.FromJson<TestItem>().Value}");
}))

Pub-Sub sample

Simple pub-sub sample showing one client that publishes and one that subscribes. This can of course be the same client and you can also have more clients subscribing etc.

Publisher

var cnInfo = new ConnectionInfo("192.168.1.10");
var client = new NatsClient(cnInfo);

await client.ConnectAsync();

await client.PubAsync("tick", GetNextTick());

//or using an encoding package e.g. Json
await client.PubAsJsonAsync("tickItem", new Tick { Value = GetNextTick() });

Subscriber

var cnInfo = new ConnectionInfo("192.168.1.10");
var client = new NatsClient(cnInfo);

await _client.ConnectAsync();

await client.SubAsync("tick", stream => stream.Subscribe(msg => {
    Console.WriteLine($"Clock ticked. Tick is {msg.GetPayloadAsString()}");
}));

//or using an encoding package e.g Json
await client.SubAsync("tickItem", stream => stream.Subscribe(msg => {
    Console.WriteLine($"Clock ticked. Tick is {msg.FromJson<TestItem>().Value}");
}))

Release Notes

https://github.com/danielwertheim/mynatsclient/releases

Showing the top 1 GitHub repositories that depend on MyNatsClient:

Repository Stars
GB28181/GB28181.Solution
Linux/Win/Docker/kubernetes/Chart/Kustomize/GB28181/SIP/RTP/SDP/WebRTC/作为上下级域/平台级联互联

Read more about the GitHub Usage information on our documentation.

Version History

Version Downloads Last updated
0.14.1 4,220 1/6/2020
0.13.0 60,199 6/29/2018
0.12.0 285 6/29/2018
0.12.0-pre1 434 5/4/2018
0.11.0 37,087 1/26/2017
0.10.0 21,535 1/10/2017
0.8.0 495 1/4/2017
0.7.0 642 12/23/2016
0.6.0 466 12/4/2016
0.5.1 529 10/18/2016
0.5.0 429 10/17/2016
0.4.0 472 10/16/2016
0.3.0 793 10/8/2016
0.3.0-b1 656 10/6/2016
0.2.1 558 6/14/2016
0.1.2 404 6/12/2016