drewww/unhangout — pull request #89 by drewww (2013-08-20 18:17:48+00:00)
Title: Hangout status app

Huge chunk of code that lays the foundation for #81, #52, and #53.

The hangout app that runs on load is now substantially more complex. A quick overview of its features:

* has a technique for electing a single "leader" to be in charge of communicating with the unhangout-server. This uses people's google ids to figure out who has the highest id, and makes that person the leader. Makes sure to only nominate people who are actually running the unhangout supervisor app. Re-elects a leader every time someone joins or leaves.
* leader sends heartbeats to the unhangout-server every five seconds
* leader sends the full current participant list to the unhangout-server whenever someone joins or leaves

This behavior gives the unhangout-server the raw data to provide a number of new pieces of data. All of these are synchronized with the client:

* there are now hangout-started and hangout-stopped events fired on the ServerSession. The hangout is assumed to start when we get any valid request from a user in that hangout. It is stopped when we fail to receive heartbeats for a few successive heartbeat periods.
* we now track which users are actually IN that hangout, in the hangoutParticipantIds list in the Session object.

The SessionView also shows these states (albeit a little bit clumsily at the moment) to users.

Also made some changes to how hangout urls are de-assigned. If someone leaves as hangout and then returns a few minutes later, Google will report that the hangout is over and direct them to start a new hangout. That new hangout will not be the same for multiple users who land on that page. To prevent this from happening, we mark hangout-url as null when we stop getting data from the hangout. This causes new hangout urls to be re-issued if someone tries to re-join that session.

This is not super well tested at this point, since a lot of these issue depend on having multiple people in the hangout to verify. But it's a first step, and we'll start testing them in earnest once we deploy them to production.