/* connectionS.pkg */ /* Connections Server v1.0 - DMS - Apr. '99 - by Marc BARILLEY */ defcom Cset = set S;; /* number */ defcom Cshow = show S;; /* number */ typeof myself=I;; typeof clients =[CLIENT r1];; fun getNb()= itoa (sizelist clients) - myself;; fun clientByCLIENT (x, cli)= x == cli;; /* comm */ fun broad (cli, comm)= _DMSsend this cli comm;; /* DMS */ fun logout (client)= set clients = remove_from_list clients client; apply_on_list clients @broad Cset [getNb]; _DMSevent this client "change" getNb nil;; fun activate (from, client, action, param, reply)= if !strcmp action "start" then { _DMSevent this client "entering" nil nil; _DMScreateClientDMI this client getNb; } else if !strcmp action "show" then _DMSsend this client Cshow [getNb] else if !strcmp action "register" then let search_in_list clients @clientByCLIENT client -> c in if c != nil then nil else { set clients = listcat clients client::nil; apply_on_list clients @broad Cset [getNb]; _DMSevent this client "change" getNb nil; } else if !strcmp action "unregister" then logout client else if !strcmp action "kill" then _DMSdelete this else nil;; fun IniDMI (file)= let strextr _getpack _checkpack file -> l in let atoi getInfo l "all" -> all in set myself=if all==1 then 0 else 1; _DMSregisterDMI this @activate @logout @logout nil;;