nookieman/TeamMeet — pull request #151 by 0x64746b (2012-05-31 22:48:22+00:00)
Title: Join race

So far we added a team object to the `XMPPService` upon successfully joining a
team. This may lead to a race condition if we asynchronously receive a key
exchange request (triggered by joining the MUC) before the team has be added,
since the exchange request needs the team object.

This commit adds the team before joining and catches potential errors when
joining. In case of a problem, the team instance is removed again and the error
re-raised.

Since saving the new team instance only manipulates the internal
state of the `XMPPService`, it shouldn't be the caller's responsibility to
remove the (otherwise transparent) team instance when handling the raised error.