publish method

void publish(
  1. String message,
  2. String subject, {
  3. String? replyTo,
})

Publishes the message to the subject with an optional replyTo set to receive the response

var client = NatsClient("localhost", 4222);
await client.connect();
client.publish("Hello World", "foo-topic");
client.publish("Hello World", "foo-topic", replyTo: "reply-topic");

Implementation

void publish(
  String message,
  String subject, {
  String? replyTo,
}) {
  if (this._protocolHandler == null)
    throw new Exception("Client not connected yet, operation not allowed");
  _protocolHandler!.publish(message, subject, replyTo: replyTo);
}