wrtc.setTimeout() is a handy way of making timeout calls of socket, line and call objects.
The normal setTimeout() function executes a command string after a specified time. There are two problems with it:
wrtc.setTimeout() takes care of these problems.
wrtc.setTimeout(obj, cmdstr, timeout)
ID value of the timer that has been set. Can be used by clearTimeout() to clear the timer.
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);
};
Making a call "hang up" on itself after 3 seconds:
wrtc.setTimeout(me, ".denyCall()", 3000);