Exemplo n.º 1
0
    def prompt(self, table_id, serialized_actions):

        # TODO: refactor to list of pending actions per table
        self.pending_actions = []
        for a in serialized_actions:
            action = loads(a)
            self.pending_actions.append(action)
Exemplo n.º 2
0
 def remote_notify(self, table_id, event):
     """
     Display an incoming event to the user.
     """
     deserialized_event = loads(event)
     logger.debug("Table %s: received event: %s" % (table_id,
         deserialized_event))
     # TODO
     self.tables[table_id].process_event(deserialized_event)
Exemplo n.º 3
0
    def open_table_success_cb(self, data):
        """ Callback for a successful table open. """
        table_view = data[0]
        table_state = loads(data[1])
        logger.debug("Table opened successfully: %s" % table_state.name)

        table = TableUplink(table_view, table_state)
        table.ui = self.ui
        self.tables[table_state.id] = table
        self.ui.open_table_success(table)
Exemplo n.º 4
0
 def get_table_list_success_cb(self, data):
     """ Called when a list of tables is received. """
     logmsg = "got table list:"
     table_listings = []
     for t in data:
         temp = loads(t)
         logmsg += "\n   %s" % temp
         table_listings.append(temp)
     logger.debug(logmsg)
     self.ui.list_tables_success(table_listings)
Exemplo n.º 5
0
    def test_simple_serialize(self):
        tuple = create_table([1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
            1000, 1000], 0)
        table = tuple[1]
        state = TableState(table)
        str = dumps(state)

        new_state = loads(str)
        self.assertEquals(state.name, new_state.name)
        self.assertEquals(10, len(new_state.seats))
Exemplo n.º 6
0
    def prompt(self, serialized_actions):
        """
        Deserialize the given actions and prompt the ui to choose one.
        """
        logger.debug("Table %s: received actions:" % self.state.id)
        try:
            deserialized_actions = []
            for action in serialized_actions:
                action = loads(action)
                logger.debug("   %s" % action)
                deserialized_actions.append(action)

            # TODO: save actions provided for client side validation

            self.ui.prompt(deserialized_actions)
        except Exception, e:
            logger.error(e)
            raise e
Exemplo n.º 7
0
 def notify(self, table_id, serialized_event):
     """
     Override the parent to track events sent.
     """
     User.notify(self, table_id, serialized_event)
     self.events.append(loads(serialized_event))