timer.js | |
---|---|
Sends messages on interval or timeout. | var toddick = require('./toddick'); |
Toddick: IntervalRepeatdly sends a message on an interval.
delay - Number of milliseconds to delay before sending each message. MSG - The messsage to send. | toddick( 'Interval', module,
{
|
Message: INITInitializes the toddick with the constructor arguments. | INIT: function(delay, MSG) {
this.monitor(MSG.toddick);
this.MSG = MSG;
this.interval_id = setInterval( this.INTERVAL.sync, delay );
},
|
Message: INTERVALSent when the interval timeout occurs. | INTERVAL: function() {
this.MSG();
},
|
Message: EXITCancels the interval timer and exits. | EXIT: function(reason, data) {
clearInterval(this.interval_id);
this.exit(reason, data);
}
}
); |
Toddick: TimeoutSends a single message after a delay.
delay - Number of milliseconds to delay before sending the message. msg - The message to send. args - An array of arguments to send with the message. | toddick( 'Timeout', module,
{
|
Message: INITInitializes the toddick using the constructor arguments. | INIT: function(delay, MSG) {
this.monitor(MSG.toddick);
this.MSG = MSG;
this.timeout_id = setTimeout( this.TIMEOUT.sync, delay);
},
|
Message: TIMEOUTSent when the tiemout occurs. | TIMEOUT: function() {
this.MSG();
this.timeout_id = undefined;
},
|
Message: timeout.exitCancels the timeout timer and exits. | EXIT: function(reason, data) {
if(this.timeout_id) {
clearTimeout(this.timeout_id);
this.timeout_id = undefined;
}
this.exit(reason, data);
}
}
);
|