.NET nuget package for connecting stomp server in client async
Install-Package Netina.Stomp.Client
IStompClient client = new StompClient("ws://xxxxx.xx");
var headers = new Dictionary<string, string>();
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.
await client.SubscribeAsync<object>("notic", new Dictionary<string, string>(), ((sender, dto) =>
{
}));
Subscribe with generic SubscribeAsync method. This method get topic and headers for STOMP SUBSCRIBE command and action for returned objects.
await client.SubscribeAsync("notic", new Dictionary<string, string>(), ((sender, stompMessage) =>
{
await client.AckAsync(stompMessage.Headers["ack"]);
}));
Subscribe and get plain STOMP message with headers, command and body. Then perform ACK operation.
await client.SendAsync(body, "notic", new Dictionary<string, string>());
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.