Skip to main content
Version: 2.13

ServiceRequest

A request consumed by a service.

Constructors​

new ServiceRequest()​

new ServiceRequest(): ServiceRequest

Returns​

ServiceRequest

Methods​

ack()​

ack(): Promise<void>

Acknowledge the request. Used for SEND requests

Returns​

Promise<void>

a Promise that completes once the ack is sent


body()​

body(): Object

Get the request body.

Returns​

Object

the request body


fail()​

fail(error): Promise<void>

Reply to the request with and error.

Parameters​

ParameterTypeDescription
errorErrorthe error to send

Returns​

Promise<void>

a Promise that completes once the error is sent


notifyOn()​

notifyOn(topic): Promise<string>

Send the topic where the requester should listen to get notifications. Used for OBSERVE requests. The string returned by the Promise is the id of that subscription. It can be used in parallel with the Service.setUnsubscriptionHandler method of the service to execute instructions when a subscription is removed.

Parameters​

ParameterTypeDescription
topicstringthe topic where the client should

Returns​

Promise<string>

a Promise that completes once the consumer has started to the listen to notifications. The


reply()​

reply(payload): Promise<void>

Send a reply to the request with a content payload. Used for GET requests

Parameters​

ParameterTypeDescription
payloadObjectthe payload of the reply

Returns​

Promise<void>

a Promise that completes once the reply is sent


requestType()​

requestType(): ServiceRequestType

Return the type of this Service Request

Returns​

ServiceRequestType

the type of this request.


userTag()​

userTag(): Promise<string>

Get the requesting client's user tag.

Returns​

Promise<string>

the user tag