def callIntoGame(self, sender, game_id, sender_callback): """another user may use this to request a game with this user sender: ConnectedUser instance that wants to play game_id: Game instance created by the sender sender_callback: function to be called when a response is obtained from the user, accepts one parameter 'accepted' as True or False""" def response_callback(response): """expects response to be a dict with a key 'accepted' and boolean value""" if response['accepted']: #self.enterGame(sender.getGameById(game_id)) self.enterGame(Game.__games__.get(game_id)) sender_callback(response['accepted']) command = ClientGameCommand.call_into(sender.db_tuple.name, game_id) self.conn.addResponseCallback(response_callback, command['trans']) self.conn.send(command)