Browse Source

added polling_stream to event api

pull/2/merge
Brett Langdon 13 years ago
parent
commit
7f2f25f88b
1 changed files with 19 additions and 0 deletions
  1. +19
    -0
      lib/api/event.js

+ 19
- 0
lib/api/event.js View File

@ -57,6 +57,25 @@ event_api.prototype.stream = function(start, end, filter, callback){
this.request('GET', '/events', params, callback); this.request('GET', '/events', params, callback);
}; };
event_api.prototype.polling_stream = function(interval, filter, callback){
if(arguments.length < 3 && v8type.is(arguments[1], v8type.FUNCTION)){
callback = arguments[1];
filter = {};
}
if(!v8type.is(filter, v8type.OBJECT)){
throw new Error('`filter` parameter must be an object');
}
var last_run = new Date().getTime() / 1000;
var self = this;
setInterval(function(){
var start = last_run;
var end = last_run = new Date().getTime() / 1000;
self.stream(start, end, filter, callback);
}, interval * 1000);
};
event_api.prototype.get_event = function(event_id, callback){ event_api.prototype.get_event = function(event_id, callback){
/* /*
* event_api.get_event(event_id, callback) * event_api.get_event(event_id, callback)


Loading…
Cancel
Save