Skip to content

Commit

Permalink
added create feed route to the worker
Browse files Browse the repository at this point in the history
  • Loading branch information
robrighter committed May 25, 2010
1 parent b47ebbc commit c8f2a2f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions worker.js
Expand Up @@ -11,21 +11,27 @@ var validhash = '.[0-9A-Za-z_\-]*';
var buffersize = 15;
var feeds = {};

sys.puts("The uuid is: " +uuid.getUuid());

//Create a feed
server.get("__create", function (req, res, match) {
//grab the hash from the query string
feeds[hash] = new lpb.LongPollingBuffer(buffersize);
return {status : "success"}
//grab the hash from the query string
var hash;
if(url.parse(req.url,true).hasOwnProperty('query') && url.parse(req.url,true).query.hasOwnProperty('hash')){
hash = parseInt(url.parse(req.url,true)['query']['hash']);
feeds[hash] = new lpb.LongPollingBuffer(buffersize);
return {status : "success"}
}
else {
return {status:'error', message:'must provide a hash for the feed to be created'};
}
});

//Get updates on a feed
server.get(new RegExp("^/latest/("+validhash+")$"), function (req, res, match) {

//first check to verify that the feed exists
if(!feeds.hasOwnProperty(match)){
return {error:'true', message:'invalid feed identifier'};
return {status:'error', message:'invalid feed identifier'};
}

buffer = feeds[match];
Expand Down

0 comments on commit c8f2a2f

Please sign in to comment.