Opening/closing event listeners across different app instances?


#1

Hi

I have an application that streams twitter feeds and inserts them into my database.

When a user logs on I run something like

// semi pseudo code and not real functions, but the general idea remains:
//
Accounts.onConnect(function(user) {
  var stream = Twitter.openStream(user);
  var stream.onTweet(function(tweet) { ... });
});

Accounts.onDisconnect(function(user) {
  stream.closeStream();
});

However, I am not sure how I can keep a reference to the stream event listener, so that I may close it once the user goes offline again, especially in a cluster with multiple instances of the application.

Any advice or suggestions on better approaches?

Thanks