/************************************************** Module Dispatcher Server Version: 1.0 Author: Laurent Hachet Last update: 22/06/2001 This module allow to dispatch the visitor to the different c3d3 cells **************************************************/ /************************************************** This file manage : **************************************************/ typeof tiiCellStatus = [[I I] r1];; /* [connectedNumber cellNumber] */ typeof iCellNumber = I;; /* the number of c3d3 cells */ typeof iConnected = I;; /* the maximum of connected for one c3d3 cell */ fun logout(cli)= _DMSevent this cli "destroyed" nil nil ;; /* change the connected number in a specific cell */ fun changeValue(l, id, newValue) = if l == nil then nil else ( let hd l -> [idCell total] in if idCell == id then mutate hd l <- [_ (total+newValue)] else changeValue tl l id newValue ) ;; /* dispatch the new connected in the cell */ fun dispatchConnected(l, cli) = if l == nil then ( _DMSevent this cli "siteFull" nil nil; _DLGMessageBox _channel nil "WARNING" "Site Full" 0; 0 ) else ( let hd l -> [idCell total] in ( /* _fooS strcat "dispatchConnected 1 (sdispatcher) " itoa total;*/ if total < iConnected then ( /* _fooS strcat "dispatchConnected 2 (sdispatcher) OK" itoa idCell;*/ mutate hd l <- [_ (total+1)]; _DMSevent this cli (strcat "in " itoa idCell) nil nil; 1 ) else dispatchConnected tl l cli ) ) ;; /* create the cell status list */ fun createCellStatus(n) = if n == (iCellNumber+1) then nil else ([n 0])::createCellStatus (n+1) ;; /* order the cell status list */ fun orderList() = let hd tiiCellStatus -> [idCell total] in ( if total < iConnected then 0 else ( set tiiCellStatus = listcat (tl tiiCellStatus) (hd tiiCellStatus)::nil; orderList ) ) ;; /* indicate if the list is full */ fun isFull(l) = if l == nil then 1 else let hd l -> [idCell total] in ( if total < iConnected then 0 else isFull tl l ) ;; fun activate(from,cli,action,param,rep)= if !strcmp action "start" then ( /* if it is the first time, create the activate list */ if tiiCellStatus == nil then set tiiCellStatus = createCellStatus 1 else nil; /* add the new connected to a cell */ dispatchConnected tiiCellStatus cli; if !isFull tiiCellStatus then ( /* _fooS "On ordonne la liste";*/ orderList ) else 0 ) else if !strcmp action "destroy" then ( _DMSdelClientDMI this cli; logout cli; 0 ) else if !strcmp (substr action 0 3) "out" then ( /* decrease the connected total in the good cell */ let atoi substr action 4 ((strlen action)-4 ) -> idCell in changeValue tiiCellStatus idCell (-1); 0 ) else nil ;; fun IniDMI(dmiFile)= /* _showconsole;*/ let strextr _getpack _checkpack dmiFile -> fileEdit in ( set iCellNumber = atoi getInfo fileEdit "cellNumber"; set iConnected = atoi getInfo fileEdit "connected" ); _DMSregisterDMI this @activate nil @logout nil ;;