7.3. Central Server - Local Demon protocol
This chapter describes the communiction protocol used between Local Demons
and Central Server. It contains:
(s) indicates that the message is received and interpreted by server
(d) indicates that the message is received and interpreded by demon
(c) indicates that the message is received by demon and forwarded to Control Applet. Interpretation takes place in Control Applet
In general there are two types of messages:
- application messages - exchanged among collaborating applications. These messages are not interpreted
by server. Server resents application messages to all other participants
of the session.
- control messages - these are messages sent by demons to change state of the server (establishing
of new sessions, adding participants, etc.)
All application messages are encapsulated in one general message type:
(d)(s) EVENT (AID, contents) - message carrying information between applications
These messages are not re-sent by the server. The contents of these messages is extracted and interpreted to perform message dependent server actions.
(s) JOIN (AT, SID) - this command is used to join the session with the application
(c) JASK (AT, SID, UID) - request for joining session sent to master of the session
(s) JANS (AT, SID, UID, yes | no) - answer for JASK sent by master of the session
(d) COMMAND (AT, params, AID, SID) - this command is send to the demon to
launch the application
(s) FINISH (AID) - command sent from the demon after an application terminates
(s) RJOIN (AT, SID. remote UID) - message used to launch application on
remote host
(c) RASK (AT, SID, local UID) - message to ack user on remote host if he/she
wants the application to be launched
(s) RANS (AT, local UID, remote UID, SID, yes | no) - answer for RASK
(c) SUPD ( add | remove | master | login | logout, SID, AT, UID, username
)
(s) MASTER (SID) - request for master
(c) MASK (SID, UID) - request for the previous master
(s) MANS (SID, UID, yes | no) - answer from previous master
(s) LOGIN (username, passwd) - login to the system
(c) LOGACC (username, UID, privileges) - login confirmation
(s) LOGOUT (UID) - logout from the system
We use the following convention: description of actions is provided with
SQL-like language with several extensions.
SEND means sending message back to the demon which sent the message currently
processed.
SEND_TO(UID) means sending a message to the demon working with user of identifier
UID.
SEND_TO_ALL means sending a message to all demons.
EVENT (AID, contents)
- SELECT SID FROM APPLICATIONS WHERE AID=AID
- SELECT AID FROM APPLICATIONS WHERE AID!=AID AND SID=SID
- INSERT INTO EVENTS (AID, contents, timestamp=getTime());
- FOR (aid IN AID) SEND_TO(getUID(AID), EVENT(AID, contents));
JOIN (AT, SID)
- if (AT in SID for UID(UID)) stop
- if (SID==0)
- SID = generate new SID;
- MASTER=UID(UID);
- INSERT INTO SESSIONS (SID, AT, MASTER);
- generate unique AID
- INSERT INTO APPLICATIONS (AID, SID, UID(UID)); ;
- SEND ( COMMAND(AT, params, AID, SID) );
- SEND_TO_ALL ( SUPD(add, SID, AT, UID(UID), username);
- SEND_TO_ALL ( SUPD(master, SID, 0, UID(UID), username);
- stop
- SELECT mUID = master FROM SESSIONS WHERE SID=SID;
- SEND_TO (mUID, JASK(UID, SID));
JANS (AT, SID, UID, yes | no)
- if "no" stop
- generate unique AID
- INSERT INTO APPLICATIONS (AID, SID, UID); ;
- SEND_TO(UID, COMMAND(AT, params, AID, SID) );
- SEND_TO_ALL ( SUPD(add, SID, AT, UID, username);
FINISH (AID)
- SELECT s=SID FROM APPLICATIONS WHERE AID=AID
- DELETE FROM APPLIATIONS WHERE AID=AID
- SELECT M=S.master FROM SESSIONS WHERE SID=s;
- if (M==UID(UID)) DELETE FROM APPLICATIONS WHERE SID=s;
- if (!SELECT count(*) FROM APPLICATIONS WHERE SID=s)
- DELETE FROM SESSIONS WHERE SID=s
- SEND_TO_ALL (SUPD(remove,SID, 0, 0, ""));
- stop;
- SEND_TO_ALL ( SUPD(remove, SID, UID(UID));
RJOIN (AT, SID. remote RUID)
- SELECT C=count(*) FROM APPLICATIONS WHERE SID=SID AND RUID=UID
- if (C>0) stop
- SEND_TO(RUID,RASK(AT, SID, UID(UID)));
RANS (AT, local UID, remote RUID, SID, yes | no)
- if (yes)
- generate unique AID
- INSERT INTO APPLICATIONS(AID, SID, UID(UID))
- SEND (COMMAND(AT, params, AID, SID))
- SEND_TO_ALL (SUPD (add, SID, AT, RUID, rusername))
MASTER (SID)
- SELECT M=MASTER FROM SESSIONS WHERE SID=SID
- if (M==UID(UID)) stop ;
- SEND_TO ( M, MASK(SID, UID(UID) );
MANS (SID, UID, yes | no)
- if (yes)
- UPDATE SESSIONS SET master=UID WHERE SID=SID;
- SEND_TO_ALL(SUPD(master, SID, AT, UID, name);
LOGIN (username, passwd)
- SELECT p=user password, u=UID FROM USERS WHERE user name=username;
- if (p==passwd)
- SEND ( LOGACC (username, UID, privileges));
- INSERT INTO PARTICIPANTS (UID,getHost());
- SEND (INFORMATION ABOUT CURRENT SESSIONS AND LOGGED USERS);
- SUPD(add, SID, AT, UID, username) - for each user in session
- SUPD(master, SID, AT, UID, username) - for each master of the session
- SUPD(login, 0, 0, UID, username) - for each user logged in
- SEND_TO_ALL(SUPD(login, 0, 0, UID(UID), username(UID))) - new user logged in
- else SEND ( LOGACC( username, 0));
LOGOUT (UID)
- SELECT a=AID FROM APPLICATIONS WHERE UID=UID;
- for (AID in a) FINISH(AID);
- DELETE FROM PARTICIPANTS WHERE UID=UID;
- SEND_TO_ALL(INFORMATION ABOUT FINISHED SESSIONS AND LOGGED OUT USER);
- SUPD(remove, SID, AT, 0, "") - for each session closed
- SUPD(remove, SID, AT, UID(UID), name) - for each session from which user UID is removed
- SUPD(logout, 0, 0, UID(UID), username(UID)) - user logs out
COMMAND (AT, params, AID, SID)
- generate free port number
- map AID to port number
- find physical path to application of type AT
- launch application with port number as one of the parameters
JASK (AT, SID, UID)
- display message box notyfiying that user UID wants to connect session SID
- get user confirmation
- SEND (JANS(UID, SID, yes | no )
SUPD ( add | remove | master | login | logout, SID, AT, UID, username )
- update information about Participants and Sessions in Control Application
EVENT (AID, contents)
- find port number mapped for the AID
- write contents to the outgoing queue on this port number
RASK (AT, SID, UID)
- display message box that user UID wants to launch application AT in session
SID
- get user confirmation
- SEND (RANS(AT, UID(UID), UID, SID, yes | no))
MASK (SID, UID)
- display message box that user UID wants to become master of session SID
- get user confirmation
- SEND (MANS(SID, UID,yes | no))
LOGACC (username, UID)
- if (UID!=0) show the information that user login was accepted
- else refuse login;