7.6.1. Demon - Central Server protocol
Messages
(s) JOIN (AT, SID) - this command is used to join the session with the application
(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
(d)(s) EVENT (AID, contents) - message carrying information between applications
(s) RJOIN (AT, SID. remote UID) - message used to launch application on
remote host
(d) 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
(d) SUPD ( add | remove | master, SID, UID) - message updating information
about virtual connection
(s) MASTER (SID) - request for master
(d) MASK (SID, UID) - request for the previous master
(s) MANS (SID, UID, yes | no) - answer from previous master
(s) LOGIN (username, passwd)
(d) LOGACC (username, UID)
(s) LOGOUT (UID)
Server actions
JOIN (AT, SID)
- if (AT in SID for UID(UID)) stop
- generate unique AID
- if (SID==0)
- SID = generate new SID;
- SELECT m=master FROM APPDETAILS WHERE AT=AT;
- MASTER=(m==TRUE?UID(UID):NULL);
- INSERT INTO SESSIONS (SID, AT, MASTER);
- INSERT INTO APPLICATIONS (AID, SID, UID(UID)); ;
- SEND ( COMMAND(AT, params, AID, SID) );
- SEND_TO_ALL ( SUPD(add, SID, UID(UID));
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;
- DELETE FROM APPLICATIONS WHERE AID=AID
- if (!SELECT count(*) FROM APPLICATIONS WHERE SID=s)
- DELETE FROM SESSIONS WHERE SID=s
- SEND (SUPD(remove,SID,0));
- stop;
- SEND ( SUPD(remove, SID, UID(UID));
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));
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
- SEND (COMMAND(AT, params, AID, SID))
- SEND_TO_ALL (SUPD (add, SID, RUID))
MASTER (SID)
- SELECT M=MASTER FROM SESSIONS WHERE SID=SID
- if (M==UID(UID) || M==NULL) 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 | UID);
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());
- 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;
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
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))
SUPD ( add | remove | master, SID, UID)
- update information about sessions
- send information about update to all interested applications
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;