Skip to content

linfulongnet/dart-websocket-nats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nats-dart

NATS client to usage in Dart CLI, Web and Flutter projects

Use WebSocket proxy NATS message, the server must be has WebSocket connection

Setting up a client

Setting up a client and firing up a connection

var client = NatsClient('ws://demo.host:port/path');
await client.connect();
...
await client.close();

Publishing a message

Publishing a message can be done with or without a reply-to topic

// No reply-to topic set
client.publish("sub-id", "foo");

// If server replies to this request, send it to `bar`
client.publish("sub-id", "foo", replyTo: "bar");

Subscribing to messages

To subscribe to a topic, specify the topic and optionally, a queue group

var subStream = client.subscribe("sub-id", "foo");

// If more than one subscriber uses the same queue group,
// only one will receive the message
var subStream = client.subscribe("sub-id", "foo", queueGroup: "group-1");

subStream.listen((message) {
    // Do something awesome
});

About

use websocket for connect to nats server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages