Skip to content
M2O Scripting APIScripting reference
Global objectServer APIGenerated

Messages

const Messages: object

Defined in: server/api.d.ts:2614

Typed request and notification channel between local resources through the global Messages object.

handle(messageType, handler): void

Registers or replaces a message handler owned by the calling resource.

string

Message type unique within the receiving resource.

MessageHandler

Handler invoked with the payload and a reply callback; the reply is ignored for notifications.

void

request(resourceName, messageType, payload?): Promise<unknown>

Sends a request to another local resource and waits for its handler to call reply.

string

Destination running resource.

string

Handler type registered by the destination.

unknown

Optional payload delivered to the handler.

Promise<unknown>

Promise resolved with the reply value or rejected when delivery or handling fails.

send(resourceName, messageType, payload?): void

Sends a fire-and-forget notification to another local resource.

string

Destination running resource.

string

Handler type registered by the destination.

unknown

Optional payload delivered to the handler.

void