let there be mroe than one TableObserver, now that lobbies are not places unto themselves
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@266 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -73,14 +73,13 @@ public class TableDirector extends BasicDirector
|
|||||||
* managing.
|
* managing.
|
||||||
* @param observer the entity that will receive callbacks when things happen to the tables.
|
* @param observer the entity that will receive callbacks when things happen to the tables.
|
||||||
*/
|
*/
|
||||||
public function TableDirector (ctx :ParlorContext, tableField :String, observer :TableObserver)
|
public function TableDirector (ctx :ParlorContext, tableField :String)
|
||||||
{
|
{
|
||||||
super(ctx);
|
super(ctx);
|
||||||
|
|
||||||
// keep track of this stuff
|
// keep track of this stuff
|
||||||
_pctx = ctx;
|
_pctx = ctx;
|
||||||
_tableField = tableField;
|
_tableField = tableField;
|
||||||
_observer = observer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,6 +107,24 @@ public class TableDirector extends BasicDirector
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests that the specified observer be added to the list of observers that are notified
|
||||||
|
* of table updates
|
||||||
|
*/
|
||||||
|
public function addTableObserver (observer :TableObserver) :void
|
||||||
|
{
|
||||||
|
_tableObservers.add(observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests that the specified observer be removed from to the list of observers that are
|
||||||
|
* notified of table updates
|
||||||
|
*/
|
||||||
|
public function removeTableObserver (observer :TableObserver) :void
|
||||||
|
{
|
||||||
|
_tableObservers.remove(observer);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the specified observer be added to the list of observers that are notified
|
* 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.
|
* when this client sits down at or stands up from a table.
|
||||||
@@ -243,8 +260,10 @@ public class TableDirector extends BasicDirector
|
|||||||
var table :Table = (event.getEntry() as Table);
|
var table :Table = (event.getEntry() as Table);
|
||||||
// check to see if we just joined a table
|
// check to see if we just joined a table
|
||||||
checkSeatedness(table);
|
checkSeatedness(table);
|
||||||
// now let the observer know what's up
|
// now let the observers know what's up
|
||||||
_observer.tableAdded(table);
|
_tableObservers.apply(function (to :TableObserver) :void {
|
||||||
|
to.tableAdded(table);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,8 +274,10 @@ public class TableDirector extends BasicDirector
|
|||||||
var table :Table = (event.getEntry() as Table);
|
var table :Table = (event.getEntry() as Table);
|
||||||
// check to see if we just joined or left a table
|
// check to see if we just joined or left a table
|
||||||
checkSeatedness(table);
|
checkSeatedness(table);
|
||||||
// now let the observer know what's up
|
// now let the observers know what's up
|
||||||
_observer.tableUpdated(table);
|
_tableObservers.apply(function (to :TableObserver) :void {
|
||||||
|
to.tableUpdated(table);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +292,9 @@ public class TableDirector extends BasicDirector
|
|||||||
notifySeatedness(false);
|
notifySeatedness(false);
|
||||||
}
|
}
|
||||||
// now let the observer know what's up
|
// now let the observer know what's up
|
||||||
_observer.tableRemoved(tableId);
|
_tableObservers.apply(function (to :TableObserver) :void {
|
||||||
|
to.tableRemoved(tableId);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,12 +374,12 @@ public class TableDirector extends BasicDirector
|
|||||||
/** The field name of the distributed set that contains our tables. */
|
/** The field name of the distributed set that contains our tables. */
|
||||||
protected var _tableField :String;
|
protected var _tableField :String;
|
||||||
|
|
||||||
/** The entity that we talk to when table stuff happens. */
|
|
||||||
protected var _observer :TableObserver;
|
|
||||||
|
|
||||||
/** The table of which we are a member if any. */
|
/** The table of which we are a member if any. */
|
||||||
protected var _ourTable :Table;
|
protected var _ourTable :Table;
|
||||||
|
|
||||||
|
/** An array of entities that want to hear about table updates. */
|
||||||
|
protected var _tableObservers :ObserverList = new ObserverList();
|
||||||
|
|
||||||
/** An array of entities that want to hear about when we stand up or sit down. */
|
/** An array of entities that want to hear about when we stand up or sit down. */
|
||||||
protected var _seatedObservers :ObserverList = new ObserverList();
|
protected var _seatedObservers :ObserverList = new ObserverList();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user