From 318d16647f128d129ca5548ea5a353c70489ce02 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Thu, 9 Jan 2003 00:26:56 +0000 Subject: [PATCH] Added mayLeavePlace(). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2103 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../crowd/client/LocationDirector.java | 14 ++++++++++++- .../crowd/client/PlaceController.java | 21 ++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/crowd/client/LocationDirector.java b/src/java/com/threerings/crowd/client/LocationDirector.java index e54d7c6de..9221329e1 100644 --- a/src/java/com/threerings/crowd/client/LocationDirector.java +++ b/src/java/com/threerings/crowd/client/LocationDirector.java @@ -1,5 +1,5 @@ // -// $Id: LocationDirector.java,v 1.27 2002/11/03 01:15:36 mdb Exp $ +// $Id: LocationDirector.java,v 1.28 2003/01/09 00:26:56 mdb Exp $ package com.threerings.crowd.client; @@ -183,6 +183,18 @@ public class LocationDirector extends BasicDirector } }); + // if we're actually going somewhere, let the controller know that + // we might be leaving + if (_controller != null) { + try { + _controller.mayLeavePlace(_plobj); + } catch (Exception e) { + Log.warning("Place controller choked in " + + "didLeavePlace [plobj=" + _plobj + "]."); + Log.logStackTrace(e); + } + } + // if we have a result listener, let it know if we failed // or keep it for later if we're still going if (rl != null) { diff --git a/src/java/com/threerings/crowd/client/PlaceController.java b/src/java/com/threerings/crowd/client/PlaceController.java index bd564b2c4..7525857d3 100644 --- a/src/java/com/threerings/crowd/client/PlaceController.java +++ b/src/java/com/threerings/crowd/client/PlaceController.java @@ -1,5 +1,5 @@ // -// $Id: PlaceController.java,v 1.10 2002/11/08 09:31:59 mdb Exp $ +// $Id: PlaceController.java,v 1.11 2003/01/09 00:26:56 mdb Exp $ package com.threerings.crowd.client; @@ -105,6 +105,25 @@ public abstract class PlaceController extends Controller }); } + /** + * Called before a request is submitted to the server to leave the + * current place. The request to leave may be rejected, but if a place + * controller needs to make a final communication to the place manager + * before it leaves, it should so do here. This is the only place in + * which the controller is guaranteed to be able to communicate to the + * place manager, as by the time {@link #didLeavePlace} is called, the + * place manager may have already been destroyed. + */ + public void mayLeavePlace (final PlaceObject plobj) + { + // let our delegates know what's up + applyToDelegates(new DelegateOp() { + public void apply (PlaceControllerDelegate delegate) { + delegate.mayLeavePlace(plobj); + } + }); + } + /** * This is called by the location director when we are leaving this * place and need to clean up after ourselves and shutdown. Derived