예제 #1
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))
예제 #2
0
파일: server.py 프로젝트: dgoodwin/rounder
 def prompt_player(self, table, username, actions):
     """ Called by a table to prompt a player with a list of actions. """
     log_msg = "Table %s: Prompting %s with actions:" % (table.id,
         username)
     serialized_actions = []
     for action in actions:
         log_msg += "\n  %s" % action
         serialized_actions.append(dumps(action))
     logger.debug(log_msg)
     self.users[username].prompt(table.id, serialized_actions)
예제 #3
0
파일: server.py 프로젝트: dgoodwin/rounder
    def open_table(self, table_id, user):
        """
        Subscribe a user to a table.

        Returns a tuple of the user's newly created table view, and a
        TableState snapshot the client can use to draw the current table
        state.
        """
        logger.debug("Opening table %s for user %s" % (table_id,
                                                       user.username))
        # TODO: check if user should be allowed to observe this table.
        table = self.table_views[table_id].table
        table.add_observer(user.username)
        state = TableState(table)
        return (self.table_views[table_id], dumps(state))
예제 #4
0
파일: server.py 프로젝트: dgoodwin/rounder
 def list_tables(self):
     """ Returns a list of visible tables to the client. """
     tables = []
     for t in self.table_views.values():
         tables.append(dumps(TableListing(t.table)))
     return tables
예제 #5
0
파일: server.py 프로젝트: dgoodwin/rounder
 def notify(self, table_id, username, event):
     serialized_event = dumps(event)
     self.users[username].notify(table_id, serialized_event)