Table of Contents

setTimeout()

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.

Arguments

wrtc.setTimeout(obj, cmdstr, timeout)

Returns

ID value of the timer that has been set. Can be used by 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);