Get your own customer support community
 

API: "Comet" connection to listen to an account's activity (tags).

I would like to be to open a "comet" (long-lived, server-push) connection to rescuetime's servers, allowing me to listen in to an account's activity -- specifically, I want to receive updates on what activity tags are currently active.

For example:

Client request: "What is johndoe12345 doing?. Here's my auth code: pazzw0rd"

Server response: "johndoe12345 is logged in. Recently active tags: news, personal, browsing. Timestamp: 2008050511031234."

Client immediately sends another request: "What has johndoe12345 been doing since 2008050511031234? Here's my auth code: pazzw0rd."

(Server has no updates on johndoe12345 since the timestamp, so it waits, keeping connection open.)

(Server gets an update from johndoe12345's data collector)

Server response: "johndoe12345 is logged in. Active tags: personal, games. Timestamp: 2008050511079821"

Client immediately sends another request: "What has johndoe12345 been doing since 2008050511079821? Here's my auth code: pazzw0rd."

... (and so on)...

This ends when client stops making requests (or drops the connection). The server can drop a connection whenever it wants, and the client is free to immediately re-request.

Note that a frequently updated RSS feed is almost as good, but in situations when the client wants near-immediate updates, this solution would be a lot easier on your servers than constant polling. I presume you're familiar with "comet" connections, but if not, just check out the wikipedia article http://en.wikipedia.org/wiki/Comet_(programming). You'd definitely want to use an event-driven server to provide this service. The most flexible solution would be sending JSONP responses.

Also note: The first response's "Active tags" just gives a list of tags that have been active in the last say...5 minutes, and never waits. The follow up responses (when the client provides a timestamp) ideally only lists the tags that have been active since the timestamp. Nevertheless, since that might entail keeping more history than is practical (especially in the case of mean-spirited requests asking for all activity since some very old timestamp), a truncated history (say 1-hour) is perfectly reasonable.

The owner of an account could limit who is allowed to listen to his activity by creating (or removing) auth codes which they give out to other services or friends. At the very least, users should be able to listen to their own accounts.

Some very useful things could be built with this kind of API. :)
 
happy I’m hopeful
Inappropriate?
2 people like this idea

User_default_medium