All the applets being a 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 create TCP/IP connection on a fixed port, send application details (AID, hostname) and start 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. 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 value will be assigned to it.
A library of shared objects will be also provided in C++. For each base type we will provide special class containing appropriate value. Instances of such classes with the same id will be shared in all applications participating in a session. Operator overloading will allow simple and powerful implementation without the need to access values of object by the use of methods.
It is also possible to implement shared variables in C. In this case special functions will be used to create and access shared variables. This library will be implemented if necessary.