Interface ServiceMsg

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

Hierarchy

  • Msg
    • ServiceMsg

Properties

data: Uint8Array

The message's data (or payload)

headers?: MsgHdrs

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

reply?: string

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

sid: number

The subscription ID where the message was dispatched.

subject: string

The subject the message was sent to

Methods

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

    Type Parameters

    • T

    Parameters

    • Optionalreviver: ReviverFn

      a reviver function

    Returns T

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

    Parameters

    • Optionalpayload: Payload
    • Optionalopts: PublishOptions

    Returns boolean

  • Parameters

    • code: number
    • description: string
    • Optionaldata: Uint8Array
    • Optionalopts: PublishOptions

    Returns boolean

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

    Returns string