def addUser(self, user): username = user.db_tuple.name for user_in_room in self.users.itervalues(): reactor.callFromThread(user_in_room.conn.send, ClientRoomCommand.adduser(self.name, username)) self.users[username] = user
def removeUser(self, user): username = user.db_tuple.name remove_game_requests(user.conn, username,self.name) try: del self.users[username] except KeyError: pass for user_in_room in self.users.itervalues(): reactor.callFromThread(user_in_room.conn.send, ClientRoomCommand.removeuser(self.name, username))
def __init__(self, name): self.name = name Room.add(self) self.chat = Chat() self.users = {} # {'name' : connected_user_instance} for cu in ConnectedUser.__users__.itervalues(): reactor.callFromThread(cu.conn.send, ClientRoomCommand.created(self.name)) self.public_games = []
def destroy(self): for cu in ConnectedUser.__users__.itervalues(): reactor.callFromThread(cu.conn.send, ClientRoomCommand.destroyed(self.name)) Room.remove(self)