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 // configure the client manager to use our client class
_clmgr.setClientFactory(new ClientFactory() { _clmgr.setClientFactory(new ClientFactory() {
public PresentsClient createClient (AuthRequest areq) { public Class<? extends PresentsClient> getClientClass (AuthRequest areq) {
return new MiCasaClient(); return MiCasaClient.class;
} }
public ClientResolver createClientResolver (Name username) { public Class<? extends ClientResolver> getClientResolverClass (Name username) {
return new ClientResolver(); return ClientResolver.class;
} }
}); });
@@ -38,7 +38,6 @@ import com.threerings.presents.client.InvocationService.ConfirmListener;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.MessageEvent; import com.threerings.presents.dobj.MessageEvent;
import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.PresentsServer;
import static com.threerings.parlor.card.Log.log; import static com.threerings.parlor.card.Log.log;
@@ -121,8 +120,7 @@ public class CardGameManager extends GameManager
} else { } else {
Hand hand = deck.dealHand(size); Hand hand = deck.dealHand(size);
if (!isAI(playerIndex)) { if (!isAI(playerIndex)) {
ClientObject clobj = (ClientObject) ClientObject clobj = (ClientObject)_omgr.getObject(_playerOids[playerIndex]);
PresentsServer.omgr.getObject(_playerOids[playerIndex]);
if (clobj != null) { if (clobj != null) {
CardGameSender.sendHand(clobj, _cardgameobj.getOid(), hand); CardGameSender.sendHand(clobj, _cardgameobj.getOid(), hand);
} }
@@ -183,8 +181,7 @@ public class CardGameManager extends GameManager
public ClientObject getClientObject (int pidx) public ClientObject getClientObject (int pidx)
{ {
if (_playerOids[pidx] != 0) { if (_playerOids[pidx] != 0) {
return (ClientObject)PresentsServer.omgr.getObject( return (ClientObject)_omgr.getObject(_playerOids[pidx]);
_playerOids[pidx]);
} else { } else {
return null; return null;
@@ -252,8 +249,8 @@ public class CardGameManager extends GameManager
} }
/** /**
* Notifies everyone in the room (other than the sender and the receiver) * Notifies everyone in the room (other than the sender and the receiver) that a set of cards
* that a set of cards have been transferred. * have been transferred.
* *
* @param fromPlayerIdx the index of the player sending the cards * @param fromPlayerIdx the index of the player sending the cards
* @param toPlayerIdx the index of the player receiving 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) { public void apply (OccupantInfo info) {
int oid = info.getBodyOid(); int oid = info.getBodyOid();
if (oid != senderOid && oid != receiverOid) { if (oid != senderOid && oid != receiverOid) {
ClientObject client = ClientObject client = (ClientObject)_omgr.getObject(oid);
(ClientObject)PresentsServer.omgr.getObject(oid);
if (client != null) { if (client != null) {
CardGameSender.cardsTransferredBetweenPlayers(client, CardGameSender.cardsTransferredBetweenPlayers(client,
fromPlayerIdx, toPlayerIdx, cards); fromPlayerIdx, toPlayerIdx, cards);
@@ -33,11 +33,10 @@ import com.threerings.util.Name;
import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.DObject;
import com.threerings.presents.server.PresentsServer;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.PlaceManager;
import com.threerings.parlor.turn.server.TurnGameManagerDelegate; import com.threerings.parlor.turn.server.TurnGameManagerDelegate;
@@ -70,10 +69,10 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
} }
@Override // from PlaceManagerDelegate @Override // from PlaceManagerDelegate
public void setPlaceManager (PlaceManager plmgr) public void didInit (PlaceConfig config)
{ {
super.setPlaceManager(plmgr); super.didInit(config);
_cgmgr = (CardGameManager)plmgr; _cgmgr = (CardGameManager)_plmgr;
} }
@Override // from PlaceManagerDelegate @Override // from PlaceManagerDelegate
@@ -85,8 +84,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
_trickCardGame = (TrickCardGameObject)plobj; _trickCardGame = (TrickCardGameObject)plobj;
_cardGame = (CardGameObject)plobj; _cardGame = (CardGameObject)plobj;
_trickCardGame.setTrickCardGameService( _trickCardGame.setTrickCardGameService(
(TrickCardGameMarshaller)PresentsServer.invmgr.registerDispatcher( (TrickCardGameMarshaller)_invmgr.registerDispatcher(new TrickCardGameDispatcher(this)));
new TrickCardGameDispatcher(this)));
} }
@Override // from PlaceManagerDelegate @Override // from PlaceManagerDelegate
@@ -94,7 +92,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
{ {
super.didShutdown(); super.didShutdown();
PresentsServer.invmgr.clearDispatcher(_trickCardGame.getTrickCardGameService()); _invmgr.clearDispatcher(_trickCardGame.getTrickCardGameService());
} }
@Override // from GameManagerDelegate @Override // from GameManagerDelegate
@@ -573,7 +571,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
} }
/** The all-purpose turn timeout interval. */ /** The all-purpose turn timeout interval. */
protected Interval _turnTimeoutInterval = new Interval(PresentsServer.omgr) { protected Interval _turnTimeoutInterval = new Interval(_omgr) {
public void expired () { public void expired () {
_turnTimedOut = true; _turnTimedOut = true;
turnTimedOut(); turnTimedOut();
@@ -581,7 +579,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
}; };
/** Calls {@link #endTrick} upon expiration. */ /** Calls {@link #endTrick} upon expiration. */
protected Interval _endTrickInterval = new Interval(PresentsServer.omgr) { protected Interval _endTrickInterval = new Interval(_omgr) {
public void expired () { public void expired () {
endTrick(); endTrick();
} }
@@ -45,7 +45,6 @@ import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.PlaceConfig; import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject; import com.threerings.crowd.data.PlaceObject;
import com.threerings.crowd.server.CrowdServer; 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.GameConfig;
import com.threerings.parlor.game.data.GameObject; 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 public abstract class RatingManagerDelegate extends GameManagerDelegate
implements RatingCodes implements RatingCodes
{ {
@Override // from PlaceManagerDelegate
public void setPlaceManager (PlaceManager plmgr)
{
super.setPlaceManager(plmgr);
_gmgr = (GameManager)plmgr;
}
@Override // from PlaceManagerDelegate @Override // from PlaceManagerDelegate
public void didInit (PlaceConfig config) public void didInit (PlaceConfig config)
{ {
super.didInit(config); super.didInit(config);
_gmgr = (GameManager)_plmgr;
_repo = getRatingRepository(); _repo = getRatingRepository();
} }
@@ -89,7 +82,7 @@ public abstract class RatingManagerDelegate extends GameManagerDelegate
super.bodyEntered(bodyOid); super.bodyEntered(bodyOid);
// if the game is in play and this is a player, load their ratings // 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)) { if (shouldRateGame() && _gobj.isInPlay() && isPlayer(occupant)) {
Rating rating = maybeCreateRating(occupant); Rating rating = maybeCreateRating(occupant);
if (rating != null) { if (rating != null) {
@@ -132,7 +125,7 @@ public abstract class RatingManagerDelegate extends GameManagerDelegate
// player id of each player position for seated table games // player id of each player position for seated table games
ArrayList<Rating> toLoad = new ArrayList<Rating>(); ArrayList<Rating> toLoad = new ArrayList<Rating>();
for (int ii = 0, ll = _gobj.occupants.size(); ii < ll; ii++) { 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()); int pidx = _gmgr.getPlayerIndex(bobj.getVisibleName());
if (pidx != -1) { if (pidx != -1) {
_playerIds[pidx] = _gmgr.getPlayerPersistentId(bobj); _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.ObjectRemovedEvent;
import com.threerings.presents.dobj.OidListListener; import com.threerings.presents.dobj.OidListListener;
import com.threerings.presents.server.InvocationException; import com.threerings.presents.server.InvocationException;
import com.threerings.presents.server.PresentsServer;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
import com.threerings.crowd.data.OccupantInfo; import com.threerings.crowd.data.OccupantInfo;
@@ -312,7 +311,7 @@ public class TableManager
*/ */
final protected Table notePlayerRemoved (int playerOid) 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 // 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); table.updateOccupants(gameObj);
_tlobj.updateTables(table); _tlobj.updateTables(table);
} }
@@ -24,8 +24,8 @@ package com.threerings.parlor.turn.server;
import com.samskivert.util.RandomUtil; import com.samskivert.util.RandomUtil;
import com.threerings.util.Name; import com.threerings.util.Name;
import com.threerings.crowd.data.PlaceConfig;
import com.threerings.crowd.data.PlaceObject; 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.GameManager;
import com.threerings.parlor.game.server.GameManagerDelegate; 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. * 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) public void didStartup (PlaceObject plobj)
{ {
_turnGame = (TurnGameObject)plobj; _turnGame = (TurnGameObject)plobj;
@@ -21,7 +21,8 @@
package com.threerings.puzzle.server; package com.threerings.puzzle.server;
import com.threerings.crowd.server.PlaceManager; import com.threerings.crowd.data.PlaceConfig;
import com.threerings.parlor.game.server.GameManagerDelegate; import com.threerings.parlor.game.server.GameManagerDelegate;
/** /**
@@ -42,10 +43,10 @@ public class PuzzleManagerDelegate extends GameManagerDelegate
} }
@Override // from PlaceManagerDelegate @Override // from PlaceManagerDelegate
public void setPlaceManager (PlaceManager plmgr) public void didInit (PlaceConfig config)
{ {
super.setPlaceManager(plmgr); super.didInit(config);
_puzmgr = (PuzzleManager)plmgr; _puzmgr = (PuzzleManager)_plmgr;
} }
protected PuzzleManager _puzmgr; protected PuzzleManager _puzmgr;
@@ -63,11 +63,11 @@ public abstract class WhirledServer extends CrowdServer
// configure the client to use our whirled client // configure the client to use our whirled client
clmgr.setClientFactory(new ClientFactory() { clmgr.setClientFactory(new ClientFactory() {
public PresentsClient createClient (AuthRequest areq) { public Class<? extends PresentsClient> getClientClass (AuthRequest areq) {
return new WhirledClient(); return WhirledClient.class;
} }
public ClientResolver createClientResolver (Name username) { public Class<? extends ClientResolver> getClientResolverClass (Name username) {
return new ClientResolver(); return ClientResolver.class;
} }
}); });