PageBox |
|
|
|
|
|
Presentation | User guide | Token API | Active naming | Extensions | Implementation | Token implementation |
Token API user guideObjectiveThis document describes how to use the token API to send and receive messages in a Web application deployed by PageBox. AudienceArchive developers. RegistrationThe Web application implements a TokenCallbackIF interface, registers and un-register this implementation on the PageBox with the registerCallback and unregisterCallback methods of PageBoxAPI. registerCallbackSignature: boolean registerCallback(TokenCallbackIF tci); registerCallback takes an instance of the class implementing the TokenCallbackIF interface as parameter and returns true in case of success. A Web application typically calls this method only once, either on load or on the first use. If the application wants to temporarily stop receiving messages it can call unregisterCallback and call registerCallback again when it is again ready to receive messages. unregisterCallbackSignature: boolean unregisterCallback(); unregisterCallback returns true in case of success. A Web application typically calls this method only once, when it is unloaded. TokenCallbackIFTo use the token API a Web application must implement the TokenCallbackIF interface, defined in the PageBoxLib package like this:
setSenderThe setSender method is called when the Web application calls registerCallback. This method has for parameter an object implementing the TokenSendIF interface. The Web application must use this object to insert messages on the ring and send these messages to other Web application instances in the constellation. The TokenSendIF interface is defined like this:
The send method allows sending messages to other Web application instances in the constellation. It takes three parameters:
send returns a correlation ID. The Web application can store this ID and use it later to correlate a response to the sent message. The isRegistered method returns true if the Web application is still registered on the ring and false otherwise. callThe Token API calls this method of the Web application TokenCallbackIF object for each message that it receives for this Web application. The call method has four parameters:
The Web application should return:
Don’t return a response if you don’t have useful information to send. When the message was broadcasted, return the smallest possible response because the original sender will receive a frame with (number of instances on the ring - 1) * messages. responseThe Token API calls this method of the Web application TokenCallbackIF object when it receives a response for a message sent by this Web application. The response method has three parameters:
pollThe Token API calls this method of the Web application TokenCallbackIF object each time it receives a frame. You can implement message sending in this method. Note: call, response and poll methods are called in this order.
Contact:support@pagebox.net |
|