/* pointsS.pkg */ /* Points Server v1.0 - DMS - Jul. '98 - by Marc BARILLEY */ /* Points Server v2.0 - DMS - Mar. '99 - by Marc BARILLEY */ var LEFT = 0;; var RIGHT = 1;; typeof state = I;; typeof initialState = I;; typeof clients = [[CLIENT I] r1];; typeof same = I;; fun clientByClient (c_i, client)= let c_i -> [c _] in c==client;; fun activate (from, client, action, param, reply)= if !strcmp action "register" then if same then nil else if isf_in_list clients @clientByClient client then nil else { set clients = [client initialState]::clients; _DMSevent this client "registered" nil nil; } else if !strcmp action "unregister" then if same then nil else { set clients = removef_from_list clients @clientByClient client; _DMSevent this client "unregistered" nil nil; } else if !strcmp action "shuntLeft" then if same then set state=LEFT else { set clients = [client LEFT]::removef_from_list clients @clientByClient client; 0 } else if !strcmp action "shuntRight" then if same then set state=RIGHT else { set clients = [client RIGHT]::removef_from_list clients @clientByClient client; 0 } else if !strcmp action "toggle" then if same then if state==RIGHT then set state=LEFT else set state=RIGHT else { let search_in_list clients @clientByClient client -> [_ s] in set clients = [client if s==RIGHT then LEFT else RIGHT]::removef_from_list clients @clientByClient client; 0 } else if !strcmp action "input" then if same then if state==RIGHT then _DMSevent this client "right" param reply else _DMSevent this client "left" param reply else let search_in_list clients @clientByClient client -> [_ s] in _DMSevent this client if s==RIGHT then "right" else "left" param reply else nil;; fun logout (client)= if same then nil else { set clients = removef_from_list clients @clientByClient client; _DMSevent this client "unregistered" nil nil; };; fun IniDMI (file)= let strextr _getpack _checkpack file -> l in { set initialState = set state = if atoi getInfo l "left" then LEFT else RIGHT; set same = let getInfo l "same" -> s in if s==nil then 0 else atoi s; }; _DMSregisterDMI this @activate @logout @logout nil;;