https://github.com/netina/netina.stomp.client
nuget package for .net to connect stomp server
https://github.com/netina/netina.stomp.client
stomp stomp-client
Last synced: 11 months ago
JSON representation
nuget package for .net to connect stomp server
- Host: GitHub
- URL: https://github.com/netina/netina.stomp.client
- Owner: Netina
- License: mit
- Created: 2021-06-14T09:44:37.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-08-25T13:36:07.000Z (almost 3 years ago)
- Last Synced: 2025-02-03T20:06:28.675Z (over 1 year ago)
- Topics: stomp, stomp-client
- Language: C#
- Homepage:
- Size: 1.36 MB
- Stars: 10
- Watchers: 0
- Forks: 9
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Netina.Stomp.Client
[](https://ci.appveyor.com/project/mrmohande3/inet-stomp-client)
[](https://www.nuget.org/packages/Netina.Stomp.Client/)
[](https://www.nuget.org/packages/Netina.Stomp.Client/)
[](https://github.com/Netina/Netina.Stomp.Client/issues)
.NET nuget package for connecting stomp server in client async
### Usage
Install-Package Netina.Stomp.Client
### 1.Add stomp url and connect
```C#
IStompClient client = new StompClient("ws://xxxxx.xx");
var headers = new Dictionary();
headers.Add("X-Authorization", "Bearer xxx");
await client.ConnectAsync(headers);
```
Here we create instance from StompClient and set STOMP url and create Dictionary for headers like your JWT. In case you have no headers set your dictionary empty. Now your client connected.
### 2.Subscribing
```C#
await client.SubscribeAsync("notic", new Dictionary(), ((sender, dto) =>
{
}));
```
Subscribe with generic SubscribeAsync method. This method get topic and headers for STOMP SUBSCRIBE command and action for returned objects.
```C#
await client.SubscribeAsync("notic", new Dictionary(), ((sender, stompMessage) =>
{
await client.AckAsync(stompMessage.Headers["ack"]);
}));
```
Subscribe and get plain STOMP message with headers, command and body. Then perform ACK operation.
### 3.Send
```C#
await client.SendAsync(body, "notic", new Dictionary());
```
Send messages with SendAsync method. This method get body object and convert it to json for sending and url method in server and header dictionary.