com.threerings.parlor.client

## Class TableDirector

- java.lang.Object
- - com.threerings.presents.client.BasicDirector
  - - com.threerings.parlor.client.TableDirector

All Implemented Interfaces:
  com.threerings.presents.client.InvocationService.InvocationListener, com.threerings.presents.client.InvocationService.ResultListener, com.threerings.presents.client.SessionObserver, com.threerings.presents.dobj.ChangeListener, com.threerings.presents.dobj.SetListener<Table>

    public class TableDirector
    extends com.threerings.presents.client.BasicDirector
    implements com.threerings.presents.dobj.SetListener<Table>, com.threerings.presents.client.InvocationService.ResultListener

As tables are created and managed within the scope of a place (a lobby), we want to fold the table management functionality into the standard hierarchy of place controllers that deal with place-related functionality on the client. Thus, instead of forcing places that expect to have tables to extend a `TableLobbyController` or something similar, we instead provide the table director which can be instantiated by the place controller (or specific table related views) to handle the table matchmaking services.

Entites that do so, will need to implement the `TableObserver` interface so that the table director can notify them when table related things happen.

The table services expect that the place object being used as a lobby in which the table matchmaking takes place implements the `TableLobbyObject` interface.

### Constructor Summary

Constructors
Constructor and Description
`TableDirector(ParlorContext ctx, String tableField, TableObserver observer)` Creates a new table director to manage tables with the specified observer which will receive callbacks when interesting table related things happen.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addSeatednessObserver(SeatednessObserver observer)` Requests that the specified observer be added to the list of observers that are notified when this client sits down at or stands up from a table.
`void` `bootPlayer(int tableId, com.threerings.util.Name target)` Sends a request to boot a player from a table.
`void` `clearTableObject()` This must be called by the entity that uses the table director when the using entity has left and is done dealing with tables.
`void` `clientDidLogoff(com.threerings.presents.client.Client client)`
`void` `createTable(TableConfig tableConfig, GameConfig config)` Sends a request to create a table with the specified game configuration.
`void` `entryAdded(com.threerings.presents.dobj.EntryAddedEvent<Table> event)`
`void` `entryRemoved(com.threerings.presents.dobj.EntryRemovedEvent<Table> event)`
`void` `entryUpdated(com.threerings.presents.dobj.EntryUpdatedEvent<Table> event)`
`Table` `getSeatedTable()` Returns the current table this client is seated at, or null.
`boolean` `isSeated()` Returns true if this client is currently seated at a table, false if they are not.
`void` `joinTable(int tableId, int position)` Sends a request to join the specified table at the specified position.
`void` `leaveTable(int tableId)` Sends a request to leave the specified table at which we are presumably seated.
`void` `removeSeatednessObserver(SeatednessObserver observer)` Requests that the specified observer be removed from to the list of observers that are notified when this client sits down at or stands up from a table.
`void` `requestFailed(String reason)`
`void` `requestProcessed(Object result)`
`void` `setTableObject(com.threerings.presents.dobj.DObject tlobj)` This must be called by the entity that uses the table director when the using entity prepares to enter and display a place.
`void` `startTableNow(int tableId)` Sends a request to have the specified table start now, even if all the seats have not yet been filled.

### Methods inherited from class com.threerings.presents.client.BasicDirector

`clientDidLogon, clientObjectDidChange, clientWillLogon, isAvailableInStandalone, setAvailableInStandalone`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### TableDirector

    public TableDirector(ParlorContext ctx,
                         String tableField,
                         TableObserver observer)

Creates a new table director to manage tables with the specified observer which will receive callbacks when interesting table related things happen.

Parameters:
  `ctx` - the parlor context in use by the client.
  `tableField` - the field name of the distributed set that contains the tables we will be managing.
  `observer` - the entity that will receive callbacks when things happen to the tables.

### Method Detail

#### setTableObject

    public void setTableObject(com.threerings.presents.dobj.DObject tlobj)

This must be called by the entity that uses the table director when the using entity prepares to enter and display a place.

#### clearTableObject

    public void clearTableObject()

This must be called by the entity that uses the table director when the using entity has left and is done dealing with tables.

#### addSeatednessObserver

    public void addSeatednessObserver(SeatednessObserver observer)

Requests that the specified observer be added to the list of observers that are notified when this client sits down at or stands up from a table.

#### removeSeatednessObserver

    public void removeSeatednessObserver(SeatednessObserver observer)

Requests that the specified observer be removed from to the list of observers that are notified when this client sits down at or stands up from a table.

#### isSeated

    public boolean isSeated()

Returns true if this client is currently seated at a table, false if they are not.

#### getSeatedTable

    public Table getSeatedTable()

Returns the current table this client is seated at, or null.

#### createTable

    public void createTable(TableConfig tableConfig,
                            GameConfig config)

Sends a request to create a table with the specified game configuration. This user will become the owner of this table and will be added to the first position in the table. The response will be communicated via the `TableObserver` interface.

#### joinTable

    public void joinTable(int tableId,
                          int position)

Sends a request to join the specified table at the specified position. The response will be communicated via the `TableObserver` interface.

#### leaveTable

    public void leaveTable(int tableId)

Sends a request to leave the specified table at which we are presumably seated. The response will be communicated via the `TableObserver` interface.

#### startTableNow

    public void startTableNow(int tableId)

Sends a request to have the specified table start now, even if all the seats have not yet been filled.

#### bootPlayer

    public void bootPlayer(int tableId,
                           com.threerings.util.Name target)

Sends a request to boot a player from a table.

#### clientDidLogoff

    public void clientDidLogoff(com.threerings.presents.client.Client client)

Specified by:
  `clientDidLogoff` in interface `com.threerings.presents.client.SessionObserver`
Overrides:
  `clientDidLogoff` in class `com.threerings.presents.client.BasicDirector`

#### entryAdded

    public void entryAdded(com.threerings.presents.dobj.EntryAddedEvent<Table> event)

Specified by:
  `entryAdded` in interface `com.threerings.presents.dobj.SetListener<Table>`

#### entryUpdated

    public void entryUpdated(com.threerings.presents.dobj.EntryUpdatedEvent<Table> event)

Specified by:
  `entryUpdated` in interface `com.threerings.presents.dobj.SetListener<Table>`

#### entryRemoved

    public void entryRemoved(com.threerings.presents.dobj.EntryRemovedEvent<Table> event)

Specified by:
  `entryRemoved` in interface `com.threerings.presents.dobj.SetListener<Table>`

#### requestProcessed

    public void requestProcessed(Object result)

Specified by:
  `requestProcessed` in interface `com.threerings.presents.client.InvocationService.ResultListener`

#### requestFailed

    public void requestFailed(String reason)

Specified by:
  `requestFailed` in interface `com.threerings.presents.client.InvocationService.InvocationListener`