Add support for differentiating properly between interesting and not

interesting tables and not publishing the not interesting tables in the table
lobby object.


git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@830 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2009-05-01 20:48:52 +00:00
parent e84a3fa3d7
commit 065d0e243f
@@ -159,7 +159,9 @@ public class TableManager
} }
// stick the table into the table lobby object // stick the table into the table lobby object
_tlobj.addToTables(table); if (shouldPublish(table)) {
_tlobj.addToTables(table);
}
// also stick it into our tables tables // also stick it into our tables tables
_tables.put(table.tableId, table); _tables.put(table.tableId, table);
@@ -226,7 +228,7 @@ public class TableManager
} }
// update the table in the lobby // update the table in the lobby
_tlobj.updateTables(table); updateTable(table);
// there is normally no success response. the client will see // there is normally no success response. the client will see
// themselves show up in the table that they joined // themselves show up in the table that they joined
@@ -266,7 +268,7 @@ public class TableManager
if (table.isEmpty()) { if (table.isEmpty()) {
purgeTable(table); purgeTable(table);
} else { } else {
_tlobj.updateTables(table); updateTable(table);
} }
// there is normally no success response. the client will see // there is normally no success response. the client will see
@@ -322,8 +324,7 @@ public class TableManager
", table=" + table + "]."); ", table=" + table + "].");
} }
table.clearPlayerPos(position); table.clearPlayerPos(position);
updateTable(table);
_tlobj.updateTables(table);
} }
/** /**
@@ -346,8 +347,11 @@ public class TableManager
// remove the mapping by gameOid // remove the mapping by gameOid
Table removed = _goidMap.remove(table.gameOid); // no-op if gameOid == 0 Table removed = _goidMap.remove(table.gameOid); // no-op if gameOid == 0
// remove the table from the lobby object // remove the table from the lobby object (the table may not have been published if a
_tlobj.removeFromTables(table.tableId); // derived class decided it was not worth publishing, see shouldPublish())
if (_tlobj.getTables().containsKey(table.tableId)) {
_tlobj.removeFromTables(table.tableId);
}
// remove the listener too so we do not get a request later on to update the occupants or // remove the listener too so we do not get a request later on to update the occupants or
// unmap this table // unmap this table
@@ -460,7 +464,12 @@ public class TableManager
gameobj.addListener(_gameListener); gameobj.addListener(_gameListener);
// and then update the lobby object that contains the table // and then update the lobby object that contains the table
_tlobj.updateTables(table); if (shouldPublish(table)) {
updateTable(table);
} else if (_tlobj.getTables().containsKey(table.tableId)) {
// or remove it if the table is no longer "interesting"
_tlobj.removeFromTables(table.tableId);
}
} }
/** /**
@@ -501,7 +510,7 @@ public class TableManager
// update this table's occupants information and update the table // update this table's occupants information and update the table
GameObject gameObj = (GameObject)_omgr.getObject(gameOid); GameObject gameObj = (GameObject)_omgr.getObject(gameOid);
table.updateOccupants(gameObj); table.updateOccupants(gameObj);
_tlobj.updateTables(table); updateTable(table);
} }
/** /**
@@ -523,12 +532,30 @@ public class TableManager
return; return;
} }
// either update or delete the table depending on whether or not we just removed the last // update or delete the table depending on whether or not we just removed the last player
// player
if (pender.isEmpty()) { if (pender.isEmpty()) {
purgeTable(pender); purgeTable(pender);
} else { } else {
_tlobj.updateTables(pender); updateTable(pender);
}
}
/**
* Derived classes can override this method to filter certain tables from being published in
* the lobby object. Such tables are probably unwatchable and unjoinable and thus just take up
* space in the lobby object for no good reason. This will be checked when the table is first
* created and when the table's game transitions to in-play.
*/
protected boolean shouldPublish (Table table)
{
return true; // we publish all tables by default
}
protected void updateTable (Table table)
{
// the table may not have been published, see shouldPublish()
if (_tlobj.getTables().containsKey(table.tableId)) {
_tlobj.updateTables(table);
} }
} }