Updated ClientFactory implementations. Use new PlaceManagerDelegate members.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@619 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2008-06-08 20:24:30 +00:00
parent e3dc42daab
commit 36c2cc8289
8 changed files with 40 additions and 53 deletions
@@ -59,11 +59,11 @@ public class MiCasaServer extends CrowdServer
// configure the client manager to use our client class
_clmgr.setClientFactory(new ClientFactory() {
public PresentsClient createClient (AuthRequest areq) {
return new MiCasaClient();
public Class<? extends PresentsClient> getClientClass (AuthRequest areq) {
return MiCasaClient.class;
}
public ClientResolver createClientResolver (Name username) {
return new ClientResolver();
public Class<? extends ClientResolver> getClientResolverClass (Name username) {
return ClientResolver.class;
}
});
@@ -38,7 +38,6 @@ import com.threerings.presents.client.InvocationService.ConfirmListener;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.MessageEvent;
import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.PresentsServer;
import static com.threerings.parlor.card.Log.log;
@@ -121,8 +120,7 @@ public class CardGameManager extends GameManager
} else {
Hand hand = deck.dealHand(size);
if (!isAI(playerIndex)) {
ClientObject clobj = (ClientObject)
PresentsServer.omgr.getObject(_playerOids[playerIndex]);
ClientObject clobj = (ClientObject)_omgr.getObject(_playerOids[playerIndex]);
if (clobj != null) {
CardGameSender.sendHand(clobj, _cardgameobj.getOid(), hand);
}
@@ -183,8 +181,7 @@ public class CardGameManager extends GameManager
public ClientObject getClientObject (int pidx)
{
if (_playerOids[pidx] != 0) {
return (ClientObject)PresentsServer.omgr.getObject(
_playerOids[pidx]);
return (ClientObject)_omgr.getObject(_playerOids[pidx]);
} else {
return null;
@@ -252,8 +249,8 @@ public class CardGameManager extends GameManager
}
/**
* Notifies everyone in the room (other than the sender and the receiver)
* that a set of cards have been transferred.
* Notifies everyone in the room (other than the sender and the receiver) that a set of cards
* have been transferred.
*
* @param fromPlayerIdx the index of the player sending the cards
* @param toPlayerIdx the index of the player receiving the cards
@@ -268,8 +265,7 @@ public class CardGameManager extends GameManager
public void apply (OccupantInfo info) {
int oid = info.getBodyOid();
if (oid != senderOid && oid != receiverOid) {
ClientObject client =
(ClientObject)PresentsServer.omgr.getObject(oid);
ClientObject client = (ClientObject)_omgr.getObject(oid);
if (client != null) {
CardGameSender.cardsTransferredBetweenPlayers(client,
fromPlayerIdx, toPlayerIdx, cards);
@@ -33,11 +33,10 @@ import com.threerings.util.Name;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.server.PresentsServer;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.PlaceManager;
import com.threerings.parlor.turn.server.TurnGameManagerDelegate;
@@ -70,10 +69,10 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
}
@Override // from PlaceManagerDelegate
public void setPlaceManager (PlaceManager plmgr)
public void didInit (PlaceConfig config)
{
super.setPlaceManager(plmgr);
_cgmgr = (CardGameManager)plmgr;
super.didInit(config);
_cgmgr = (CardGameManager)_plmgr;
}
@Override // from PlaceManagerDelegate
@@ -85,8 +84,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
_trickCardGame = (TrickCardGameObject)plobj;
_cardGame = (CardGameObject)plobj;
_trickCardGame.setTrickCardGameService(
(TrickCardGameMarshaller)PresentsServer.invmgr.registerDispatcher(
new TrickCardGameDispatcher(this)));
(TrickCardGameMarshaller)_invmgr.registerDispatcher(new TrickCardGameDispatcher(this)));
}
@Override // from PlaceManagerDelegate
@@ -94,7 +92,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
{
super.didShutdown();
PresentsServer.invmgr.clearDispatcher(_trickCardGame.getTrickCardGameService());
_invmgr.clearDispatcher(_trickCardGame.getTrickCardGameService());
}
@Override // from GameManagerDelegate
@@ -573,7 +571,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
}
/** The all-purpose turn timeout interval. */
protected Interval _turnTimeoutInterval = new Interval(PresentsServer.omgr) {
protected Interval _turnTimeoutInterval = new Interval(_omgr) {
public void expired () {
_turnTimedOut = true;
turnTimedOut();
@@ -581,7 +579,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
};
/** Calls {@link #endTrick} upon expiration. */
protected Interval _endTrickInterval = new Interval(PresentsServer.omgr) {
protected Interval _endTrickInterval = new Interval(_omgr) {
public void expired () {
endTrick();
}
@@ -45,7 +45,6 @@ import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.CrowdServer;
import com.threerings.crowd.server.PlaceManager;
import com.threerings.parlor.game.data.GameConfig;
import com.threerings.parlor.game.data.GameObject;
@@ -62,17 +61,11 @@ import com.threerings.parlor.rating.server.persist.RatingRepository;
public abstract class RatingManagerDelegate extends GameManagerDelegate
implements RatingCodes
{
@Override // from PlaceManagerDelegate
public void setPlaceManager (PlaceManager plmgr)
{
super.setPlaceManager(plmgr);
_gmgr = (GameManager)plmgr;
}
@Override // from PlaceManagerDelegate
public void didInit (PlaceConfig config)
{
super.didInit(config);
_gmgr = (GameManager)_plmgr;
_repo = getRatingRepository();
}
@@ -89,7 +82,7 @@ public abstract class RatingManagerDelegate extends GameManagerDelegate
super.bodyEntered(bodyOid);
// if the game is in play and this is a player, load their ratings
BodyObject occupant = (BodyObject)CrowdServer.omgr.getObject(bodyOid);
BodyObject occupant = (BodyObject)_omgr.getObject(bodyOid);
if (shouldRateGame() && _gobj.isInPlay() && isPlayer(occupant)) {
Rating rating = maybeCreateRating(occupant);
if (rating != null) {
@@ -132,7 +125,7 @@ public abstract class RatingManagerDelegate extends GameManagerDelegate
// player id of each player position for seated table games
ArrayList<Rating> toLoad = new ArrayList<Rating>();
for (int ii = 0, ll = _gobj.occupants.size(); ii < ll; ii++) {
BodyObject bobj = (BodyObject)CrowdServer.omgr.getObject(_gobj.occupants.get(ii));
BodyObject bobj = (BodyObject)_omgr.getObject(_gobj.occupants.get(ii));
int pidx = _gmgr.getPlayerIndex(bobj.getVisibleName());
if (pidx != -1) {
_playerIds[pidx] = _gmgr.getPlayerPersistentId(bobj);
@@ -40,7 +40,6 @@ import com.threerings.presents.dobj.ObjectDestroyedEvent;
import com.threerings.presents.dobj.ObjectRemovedEvent;
import com.threerings.presents.dobj.OidListListener;
import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.PresentsServer;
import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.OccupantInfo;
@@ -312,7 +311,7 @@ public class TableManager
*/
final protected Table notePlayerRemoved (int playerOid)
{
return notePlayerRemoved(playerOid, (BodyObject) PresentsServer.omgr.getObject(playerOid));
return notePlayerRemoved(playerOid, (BodyObject) CrowdServer.omgr.getObject(playerOid));
}
/**
@@ -438,7 +437,7 @@ public class TableManager
}
// update this table's occupants information and update the table
GameObject gameObj = (GameObject) PresentsServer.omgr.getObject(gameOid);
GameObject gameObj = (GameObject) CrowdServer.omgr.getObject(gameOid);
table.updateOccupants(gameObj);
_tlobj.updateTables(table);
}
@@ -24,8 +24,8 @@ package com.threerings.parlor.turn.server;
import com.samskivert.util.RandomUtil;
import com.threerings.util.Name;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.PlaceManager;
import com.threerings.parlor.game.server.GameManager;
import com.threerings.parlor.game.server.GameManagerDelegate;
@@ -53,13 +53,6 @@ public class TurnGameManagerDelegate extends GameManagerDelegate
{
}
@Override // from PlaceManagerDelegate
public void setPlaceManager (PlaceManager plmgr)
{
super.setPlaceManager(plmgr);
_tgmgr = (TurnGameManager)plmgr;
}
/**
* Returns the index of the current turn holder as configured in the game object.
*
@@ -154,7 +147,14 @@ public class TurnGameManagerDelegate extends GameManagerDelegate
}
}
// documentation inherited
@Override // from PlaceManagerDelegate
public void didInit (PlaceConfig config)
{
super.didInit(config);
_tgmgr = (TurnGameManager)_plmgr;
}
@Override // from PlaceManagerDelegate
public void didStartup (PlaceObject plobj)
{
_turnGame = (TurnGameObject)plobj;
@@ -21,7 +21,8 @@
package com.threerings.puzzle.server;
import com.threerings.crowd.server.PlaceManager;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.parlor.game.server.GameManagerDelegate;
/**
@@ -42,10 +43,10 @@ public class PuzzleManagerDelegate extends GameManagerDelegate
}
@Override // from PlaceManagerDelegate
public void setPlaceManager (PlaceManager plmgr)
public void didInit (PlaceConfig config)
{
super.setPlaceManager(plmgr);
_puzmgr = (PuzzleManager)plmgr;
super.didInit(config);
_puzmgr = (PuzzleManager)_plmgr;
}
protected PuzzleManager _puzmgr;
@@ -63,11 +63,11 @@ public abstract class WhirledServer extends CrowdServer
// configure the client to use our whirled client
clmgr.setClientFactory(new ClientFactory() {
public PresentsClient createClient (AuthRequest areq) {
return new WhirledClient();
public Class<? extends PresentsClient> getClientClass (AuthRequest areq) {
return WhirledClient.class;
}
public ClientResolver createClientResolver (Name username) {
return new ClientResolver();
public Class<? extends ClientResolver> getClientResolverClass (Name username) {
return ClientResolver.class;
}
});