Skip to main content

Overview

Registers (or unregisters) an event handler on the client, that gets called when the account receives an XMPP message of a given type. When such a message is received that matches a registered event handler, the message is pushed as a client event to the client, instead of being stored on the broker, as an offline message. Note: For client events to be received on the client, you need to include the /Events.js javascript file on the page. This javascript file will register the current tab with the server, and enable it to receive asynchronous events from the server. If you are hosting the page on one server, and use the Agent API and Events API from another server, you need to include a meta header on the page, information the /Events.js javascript file where it will register itself to receive client events. To use this neuron, add the following to the HTML header of your page: You also need to inform the AgentAPI that you want to use another host, than the server used to host the page. You do this by making a call to AgentAPI.IO.SetHost(Host,Secure) as follows:

HTTP request

POST /Agent/Xmpp/RegisterEventHandler

Authentication

Requires a valid JWT bearer token.

Request (JSON)

{
	"localName":Optional(Str(PLocalName)),
	"namespace":Optional(Str(PNamespace)),
	"type":Optional(Str(PType)),
	"function":Optional(Str(PFunction)),
	"tabId":Required(Str(PTabId))
}

Input parameters

ParameterDescription
PLocalNameOptional local name of content in message. If not provided, event handler is used for all messages of the same type and namespace that lack specific event handlers.
PNamespaceOptional Namespace of content in message. If not provided, event handler is used for all messages of the same type that lack more specific event handlers.
PTypeOptional type of message stanza. If not provided, event handler is used for all messages that lack more specific event handlers.
PFunctionFunction on client that gets called when a message of the corresponding local name, namespace and/or type is received. If left empty, the corresponding event handler is unregistered.
TabIdThe Tab ID to which events are sent when corresponding messages are received.

Response (JSON)

{
}

Notes

This endpoint uses the request schema notation described in Pattern matching.