Skip to content

Commit

Permalink
Fix listening to multiple rooms. Was starting reactor on first room a…
Browse files Browse the repository at this point in the history
…nd not waiting until all rooms were setup. Also actually call shutdown function
  • Loading branch information
askedrelic committed Oct 3, 2011
1 parent 97d0027 commit 040f214
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions campy/campy.py
Expand Up @@ -73,9 +73,12 @@ def callback(message):
def errback(message):
print message

# Setup all rooms first
for room in self.rooms:
room.listen(callback, errback)
room.listen(callback, errback, False)

# Then start listening to those rooms
reactor.run()

def die(self):
for room in self.rooms:
Expand All @@ -87,6 +90,8 @@ def die(self):

if __name__ == "__main__":
campy = Campy()

# Try to gracefully shutdown
reactor.addSystemEventTrigger('before','shutdown',campy.die)

campy.listen()
reactor.run()
campy.die()

0 comments on commit 040f214

Please sign in to comment.