/* Sound Dialog plugin - DMS2 - April 00 - by Sébastien DENEUX*/ typeof class = S;; var NbPluginInstance=0;; /*use to limit the number of instances (limited at 1 per c3D)*/ typeof clisRegistered = [[I S] r1];; /*list of the clients that have registered (that have their speaker on) id + udp*/ /*-------------*/ fun who(elt,p)= let p -> [cli ui] in let elt->[id udp] in UsendCli this cli ui "addClientInRegisteredList" (linebuild (itoa id)::udp::nil);; /*-------------*/ fun clibyid(a,id)=let a->[currentId _] in currentId==id;; /*-------------*/ fun cbcomm(ui,cli,action,param)= if !strcmp action "register" then /*a client puts his speaker on*/ let _DMSgetId cli -> id in if (search_in_list clisRegistered @clibyid id) != nil then nil /*if client already in list*/ else let _DMSgetIP cli -> chntry in let if !strcmp chntry "127.0.0.1" then _hostIP else chntry -> chnok in let strcat strcat chnok ":" param -> udp in ( /*_fooS "SERVER cbcomm register"; _fooS strcat "**chntry = " chntry; _fooS strcat "**udp = " udp; _fooS strcat "**id = " id;*/ /*send to new client the id + udp of the clients that have registered*/ apply_on_list clisRegistered @who [cli ui]; /*add the new client to the list*/ set clisRegistered = [id udp]::clisRegistered; /*id + udp*/ /*inform all clients that a new client has put his speaker on*/ UsendCli this nil ui "addClientInRegisteredList" (linebuild (itoa id)::udp::nil); /* param= id + udp new user*/ 0 ) else if !strcmp action "silent" then /*a client puts his speaker off*/ let _DMSgetId cli -> id in ( /*_fooS "SERVER cbcomm silent"; _fooS strcat "id = " id;*/ /*remove client from list*/ let search_in_list clisRegistered @clibyid id -> elt in if elt==nil then nil else set clisRegistered=remove_from_list clisRegistered elt; UsendCli this nil ui "removeClientfromRegisteredList" (itoa id); /*inform all clients that the client has put his speaker off*/ 0; ) else 0;; /*-------------*/ fun cbDelCli(o,cli)= let _DMSgetId cli -> id in let search_in_list clisRegistered @clibyid id -> elt in if elt==nil then nil else ( set clisRegistered=remove_from_list clisRegistered elt; UsendCli this nil ObUi o "removeClientfromRegisteredList" itoa id );; /*-------------*/ fun newOb(o)= if (NbPluginInstance == 0) then ( UcbComm this (ObUi o) @cbcomm; OB_CBclientDestroyed o @cbDelCli; set NbPluginInstance = NbPluginInstance + 1 ) else ( _DLGMessageBox _channel nil "Warning" " Too many soundDialog instanced.\nOnly one instance per C3d module instance is possible.\nOnly the first instance will be used." 0; set NbPluginInstance = NbPluginInstance + 1 );; /*-------------*/ fun IniPlug(file)= set class=getInfo strextr _getpack _checkpack file "name"; PlugRegister class @newOb nil; 0;;