/* Meeting Point Server v1.0 - DMS - mar 98 - by Marc BARILLEY */ defcom Chide = hide;; defcom Cshow = show;; defcom Cdestroy = destroy;; defcom CaddUser = addUser S S;; defcom CdelUser = delUser S;; defcom Cchglogin = chglogin S S;; struct StrClient = [ CLIENTClient : CLIENT, nicknameClient : S, ipClient : S, emailClient : S ] mkClient;; typeof clients =[StrClient r1];; proto logout = fun [CLIENT] I;; /* internal */ fun clientByCLIENT (x, cli)= x.CLIENTClient == cli;; fun clientByNickname (x, nickname)= !strcmp x.nicknameClient nickname;; /* comm */ fun broad (strcli, comm)= _DMSsend this strcli.CLIENTClient comm;; fun register ()= let search_in_list clients @clientByCLIENT DMSsender -> c in if c != nil then nil else { /* !!! filouterie !!! attend _DMSgetRes */ /**/ apply_on_list clients @broad CaddUser [(_DMSgetLogin DMSsender) ""]; set clients = listcat clients (mkClient [DMSsender (_DMSgetLogin DMSsender) (_channelIP DMSsender.chnCLI) ""])::nil; /**/ /* apply_on_list clients @broad CaddUser [(_DMSgetRes DMSsender "nickname") (_DMSgetRes DMSsender "email")]; set clients = listcat clients (mkClient [DMSsender (_DMSgetRes DMSsender "nickname") (_channelIP DMSsender.chnCLI) (_DMSgetRes DMSsender "email")])::nil; */ };; fun __contact (nickname)= let search_in_list clients @clientByNickname nickname -> c in if c != nil then { _DMSevent this DMSsender "contact" (strbuild (c.ipClient::nickname::c.emailClient::nil)::nil) nil; _DMSevent this DMSsender "select" (itoa _DMSgetId c.CLIENTClient) nil; } else nil;; fun __started ()= let clients -> l in while l != nil do { let hd l -> c in _DMSsend this DMSsender CaddUser [c.nicknameClient c.emailClient]; set l = tl l; }; _DMSevent this DMSsender "entering" nil nil; register;; fun __closed ()= logout DMSsender;; /* DMS */ fun logout (cli)= let search_in_list clients @clientByCLIENT cli -> c in if c != nil then { set clients = remove_from_list clients c; apply_on_list clients @broad CdelUser [/*_DMSgetLogin cli*/c.nicknameClient]; } else nil; _DMSevent this cli "destroyed" nil nil;; fun activate (from, client, action, param, reply)= if !strcmp action "start" then _DMScreateClientDMI this client nil else if !strcmp action "destroy" then _DMSsend this client Cdestroy [] else if !strcmp action "!changeLogin" then { let search_in_list clients @clientByCLIENT client -> c in set c.nicknameClient = _DMSgetLogin client; apply_on_list clients @broad Cchglogin [param (_DMSgetLogin client)] } else if !strcmp action "show" then _DMSsend this client Cshow [] else if !strcmp action "hide" then _DMSsend this client Chide [] else nil;; fun IniDMI (file)= _DMSregisterDMI this @activate @logout @logout nil;;