Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Msg

import type { Msg } from "https://raw.githubusercontent.com/nats-io/nats.deno/v1.27.0/nats-base-client/internal_mod.ts";

Represents a message delivered by NATS. This interface is used by Subscribers.

interface Msg {
data: Uint8Array;
headers?: MsgHdrs;
reply?: string;
sid: number;
subject: string;
json<T>(reviver?: ReviverFn): T;
respond(payload?: Payload, opts?: PublishOptions): boolean;
string(): string;
}

§Properties

§
data: Uint8Array
[src]

The message's data (or payload)

§
headers?: MsgHdrs
[src]

Possible headers that may have been set by the server or the publisher.

§
reply?: string
[src]

A possible subject where the recipient may publish a reply (in the cases where the message represents a request).

§
sid: number
[src]

The subscription ID where the message was dispatched.

§
subject: string
[src]

The subject the message was sent to

§Methods

§
json<T>(reviver?: ReviverFn): T
[src]

Convenience method to parse the message payload as JSON. This method will throw an exception if there's a parsing error;

@param reviver

a reviver function

§
respond(payload?: Payload, opts?: PublishOptions): boolean
[src]

Convenience to publish a response to the {@link reply} subject in the message - this is the same as doing nc.publish(msg.reply, ...).

@param payload
@param opts
§
string(): string
[src]

Convenience method to parse the message payload as string. This method may throw an exception if there's a conversion error