Skip to content

API classes

Jordi Mariné Fort edited this page Feb 2, 2014 · 23 revisions

##### WampBroker methods #####

It provides Pub/Sub communications between the publishers and consumers. It has the following methods to help the development of modules:

  • createTopic(WampApplication app, String topicFQname, WampTopicOptions options): dinamically creates a new topic to be used by WAMP clients.

  • getTopic(String topicFQname): gets a WampTopic by its fully qualified name.

  • removeTopic(WampApplication app, String topicFQname): dinamically removes a topic.

  • publishEvent(Long id, WampTopic wampTopic, WampList payload, WampDict payloadKw, Set eligible, Set exclude, Long publisherId): broadcasts an EVENT message with the "event" object data to the "eligible" list of clients (sessionIds), with the exception of the clients in the "excluded" list (sessionIds).

  • publishMetaEvent(Long id, WampTopic wampTopic, String metatopic, WampDict metaEventDetails, Long toClient): broadcasts a METAEVENT message with the "metatopic" and "metaEventDetails" information to all subscribed clients, or only to an specific client (when toClient is not null).


##### WampApplication methods #####

It has the following methods to development custom modules:

  • registerWampModule(Class moduleClass): registers a custom WampModule to the application.

##### WampEndpoint methods ##### It represents a websocket endpoint (URI), and implements the WAMP specification. It has the following methods:
  • getWampApplication(): return a reference to the WAMP services provider.

  • getSession(): returns the current websocket's session

  • onApplicationStart(): it can be overriden to intercept the first time that the endpoint class is created, and initialize the needed topics and WAMP modules for the websocket application.


##### WampException methods ######

It allows to propagate error information to clients (to generate ERROR messages).

  • **(WampDict errorDetails, String errorURI, WampList args, WampDict argsKw) **: Constructor

##### WampModule methods #####

This is an abstract class that provides interceptor methods for WAMP events:

  • getBaseURL(): it must be overriden to return the base URI of the RPCs / topic events to intercept.

  • getWampApplication(): obtains a reference to the module's application context.

  • onConnect(WebSocket client): called when a client is connected to the application (URI).

  • onDisconnect(WebSocket client): called when a client is disconnected from the application (URI).

  • onCall(WebSocket client, String method, ArrayNode args): it can be overriden to add new RPCs.

  • onSubscribe(WampSocket client, WampTopic topic, WampSubscriptionOptions options): it can be overriden to intercept subscription requests to the topics. In this case, remember to call the superclass method before/after your business logic. (i.e: to send an EVENT to the client, the method should be called before the publication).

  • onUnsubscribe(WampSocket client, WampTopic topic): it can be overriden to intercept unsubscription requests to the topics. Also, rembember to cal the superclass method before/after your business logic.

  • onPublish(WampSocket sourceClient, WampTopic topic, ArrayNode request): it can be overriden to intercept publish messages from clients. Remember to call the superclass method before/after your business logic.


##### WampSocket methods #####

It represents a connection with a WAMP client, and provides the following methods:

  • isActive(): return true when the underlying socket is open.

  • normalizeURI(String curie): converts a CURIE to a fully qualified URI (using PREFIXES registered by the client).

  • publishEvent(WampTopic topic, JsonNode event, boolean excludeMe): broadcasts an EVENT message with the "event" object data to all clients subscribed in the topic (with the possibility to exclude the publisher).


##### WampTopic methods ######

It represents a topic for PubSub services, and provides the following methods:

  • getURI(): gets its topicURI.

  • getSocketIds(): gets a list of sessionId of clients subscribed to the topic.

  • getSubscription(String sessionId): gets subscription information for the client with the specified sessionId.

Clone this wiki locally