NATS client to usage in Dart CLI, Web and Flutter projects
Documentation is generated using the dartdoc
tool
dartdoc
pub global activate dhttpd
dhttpd --path doc/api
Navigate to http://localhost:8080 and voila!! 💥
Setting up a client and firing up a connection
var client = NatsClient("localhost", 4222);
await client.connect();
Note: Never use a client without waiting for the connection to establish
var client = NatsClient("localhost", 4222);
await client.connect(onClusterupdate: (serverInfo) {
// Something changed on the server.
// May be a new server came up,
// Or something reeeeaallly bad happened
// Hmmmm ...
});
Publishing a message can be done with or without a reply-to
topic
// No reply-to topic set
client.publish("Hello world", "foo");
// If server replies to this request, send it to `bar`
client.publish("Hello world", "foo", replyTo: "bar");
To subscribe to a topic, specify the topic and optionally, a queue group
var messageStream = client.subscribe("sub-id", "foo");
// If more than one subscriber uses the same queue group,
// only one will receive the message
var messageStream = client.subscribe("sub-id", "foo", queueGroup: "group-1");
messageStream.listen((message) {
// Do something awesome
});
- Support clustered nats servers
- Support multiple topic subscriptions
- No rules. Fork, change, PR.
Not yet. The API is not yet finalised NATS protocol is not fully supported.
Soon I guess. Feel free to pitch in and it'll be ready sooner.