====== setTimeout() ====== wrtc.setTimeout() is a handy way of making timeout calls of socket, line and call objects. The normal [[https://www.w3schools.com/jsref/met_win_settimeout.asp|setTimeout()]] function executes a command string after a specified time. There are two problems with it: * How to specify which object to call after the timeout. Is it call 1, 2 or 3 that should be ended? * What to do if the specified call object doesn't exist any more? If it has been destroyed during the timeout. wrtc.setTimeout() takes care of these problems. ===== Arguments ===== wrtc.setTimeout(obj, cmdstr, timeout) * obj - the object to be called after the timeout * cmdstr - string containing the command to be executed on that object, string should start with '.', see example below * timeout - time in milliseconds before making the call (1000 is one second) ===== Returns ===== ID value of the timer that has been set. Can be used by [[https://www.w3schools.com/jsref/met_win_cleartimeout.asp|clearTimeout()]] to clear the timer. ===== Code ===== this.setTimeout = function(obj, funcstr, timeout) { if (obj.objType == "line") return setTimeout('if((' + obj.socket.nam + ') && (' + obj.nam + ')) {' + obj.nam + funcstr + '}', timeout); else return setTimeout('if(' + obj.nam + ') {' + obj.nam + funcstr + '}', timeout); }; ===== Example ===== Making a call "hang up" on itself after 3 seconds: wrtc.setTimeout(me, ".denyCall()", 3000);