(s) APPEVENT (AID, contents) - add event to the database
(s) APPDEMON() - register demon as applet demon
(d) TUPD (add | remove, AID, SID) - update apple demon table
(s) CONNCONF (aid) - confirmation that the applet with AID may start (preceeds sending COMMAND
APPEVENT (AID, contents)
APPDEMON()
APPCONF(aid)
All the applets which want to be part of the system will have to extend their main class from our class CApplet. CApplet class will provide the following methods:
abstract class Message {
}
The init method will initialize communication with AD. It will read AID written as HTML applet parameter, make TCP/IP connection on the fixed port, send application details (AID, hostname) and starts communication channels.
The send method will send messages to the AD.
The processAsynchronously() method will determine if incoming message has to be processed immediately or stored in message queue. In the first case it should return true, in latter false.
The createMessage() will create new object of Message class or its subclass based on incoming table of bytes. This method will be called each time a new message arrives. If application handles messages asynchronously the handleMessage() method will be invoked. Otherwise message will be put to the message queue and may be read by getMessage() method later. If a message has 'asynchronous' field set to true it has to be handled asynchronously regardless of the state of processAsynchronously() method.
The getMessage() method will return first message waiting in the message queue or null if there are no messages waiting.
The handleMessage() method will provide means to process incoming message. This message will be called each time a new message comes. It will be responsibility of each applet to handle the message correctly.
With the system we will provide classes to implement shared variables. Shared variable is an object that whenever it gets updated in one application, it causes other running applications in the same type to change the state of this object accordingly.
In time of creation each shared object will be assigned with unique id number. This number will be passed to object in constructor together with reference to the main system class (CApplet). Each time an object is updated with use of its set() method, the message with 'asynchronous' flag will be sent with new value and object id. Each time such a message is received the proper object will be found on the base of object id and the new valuse will be assigned to it.