MyNatsClient.Encodings.Json
0.14.1
JSON Encoding for assisting with sending and consuming JSON messages using MyNatsClient which 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.
See the version list below for details.
Install-Package MyNatsClient.Encodings.Json -Version 0.14.1
dotnet add package MyNatsClient.Encodings.Json --version 0.14.1
<PackageReference Include="MyNatsClient.Encodings.Json" Version="0.14.1" />
paket add MyNatsClient.Encodings.Json --version 0.14.1
#r "nuget: MyNatsClient.Encodings.Json, 0.14.1"
// Install MyNatsClient.Encodings.Json as a Cake Addin
#addin nuget:?package=MyNatsClient.Encodings.Json&version=0.14.1
// Install MyNatsClient.Encodings.Json as a Cake Tool
#tool nuget:?package=MyNatsClient.Encodings.Json&version=0.14.1
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
Dependencies
-
.NETStandard 2.1
- MyNatsClient (>= 0.14.1)
- Newtonsoft.Json (>= 12.0.3)
Used By
NuGet packages (3)
Showing the top 3 NuGet packages that depend on MyNatsClient.Encodings.Json:
Package | Downloads |
---|---|
Serilog.Sinks.Nats
Serilog sink for NATS messaging server
|
|
Mi.Fx.Nats
macula.io Nats abstraction
|
|
Mi.Fx.Contract
Package Description
|
GitHub repositories
This package is not used by any popular GitHub repositories.
Version History
Version | Downloads | Last updated |
---|---|---|
0.18.2 | 504 | 3/18/2021 |
0.18.1 | 169 | 3/11/2021 |
0.18.0 | 58 | 3/10/2021 |
0.17.1 | 55 | 3/9/2021 |
0.17.0 | 1,477 | 10/16/2020 |
0.16.1 | 739 | 9/19/2020 |
0.16.0 | 199 | 9/19/2020 |
0.15.0 | 231 | 9/19/2020 |
0.14.3 | 854 | 8/25/2020 |
0.14.2 | 193 | 8/16/2020 |
0.14.1 | 8,968 | 1/6/2020 |
0.13.0 | 30,301 | 6/29/2018 |
0.12.0 | 444 | 6/29/2018 |
0.12.0-pre1 | 600 | 5/4/2018 |
0.11.0 | 8,495 | 1/26/2017 |
0.10.0 | 598 | 1/10/2017 |