var u = buildURI(uri, {id: params.id, when: "open", transport: "longpolljsonp", callback: "dayoff"});
transport.uri = u;
req = http.get(u)
.on("error", function(error) {
transport.emit("error", error);
})
.on("response", function() {
poll([]);
transport.emit("open");
function poll(lastEventIds) {
req = http.get(buildURI(uri, {id: params.id, when: "poll", lastEventIds: lastEventIds.join(",")}))
.on("error", function(error) {
transport.emit("error", error);
})
.on("response", function(res) {
var body = "";
res.on("error", function(error) {
transport.emit("error", error);
})
.on("data", function(chunk) {
body += chunk;
})
.on("end", function() {
if (body) {