/******************************************************************************* Plugin Template Server part Version: 1.0 Authors: Sebastien DENEUX & Julien Zorko Last update: 09/05/2001 Template Plugin *******************************************************************************/ /******************************************************************************* This plugin is a template plugin which allows to understand the basic rules for plugins implentation. Its function is not usefull: it applies a flat color on the objects of an anchor and randomly changes this color when the user clicks on one of them. The mouse cursor shape changes when it is on one of these clickable objects. The random color comes from a server function and all the clients see the new color. *******************************************************************************/ typeof class = S;; /* Plugin class name (here is template) */ /******************************************************************************* Click action Callback ui -> UserI : user instance cli -> Client : client action -> S : action param -> S : parameters z -> [Ob I] : Ob and flat color <- I : not used *******************************************************************************/ fun cbClick (ui, cli, action, param, z)= let z->[o col] in ( set col = (rand&255)+((rand&255)<<8)+((rand&255)<<16); mutate z <- [_ col]; UsendMessage ui nil "setFlat" itoa col ) ;; /******************************************************************************* Callback to reply to a new color request action ui -> UserI : user instance cli -> Client : client action -> S : action param -> S : parameters z -> [Ob I] : Ob and flat color <- I : not used *******************************************************************************/ fun cbAskColor (ui, cli, act, param, z)= let z->[o col] in UsendMessage ui cli "setFlat" itoa col ;; /******************************************************************************* New object creation o -> Ob : object <- I : not used *******************************************************************************/ fun newOb (o)= let [o 1] -> z in UcbMessage ObUi o ["click" mkfun5 @cbClick z]::["color?" mkfun5 @cbAskColor z]::nil; 0 ;; /******************************************************************************* Function called when plugin is initialised file -> S : '*.plug' file name <- I : not used *******************************************************************************/ fun IniPlug (file)= set class=getInfo strextr _getpack _checkpack file "name"; PlugRegister class @newOb nil; 0 ;;