Allow a SceneService.moveTo() to respond by requesting that the client move to
a new server and reissue its request, which it, in theory, now does. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@354 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -32,6 +32,7 @@ import com.threerings.io.TypedArray;
|
||||
import com.threerings.presents.client.BasicDirector;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.ClientEvent;
|
||||
import com.threerings.presents.client.ConfirmAdapter;
|
||||
import com.threerings.presents.data.InvocationCodes;
|
||||
|
||||
import com.threerings.crowd.client.LocationDirector;
|
||||
@@ -138,16 +139,8 @@ public class SceneDirector extends BasicDirector
|
||||
return false;
|
||||
}
|
||||
|
||||
// check the version of our cached copy of the scene to which we're requesting to move; if
|
||||
// we were unable to load it, assume a cached version of zero
|
||||
var sceneVers :int = 0;
|
||||
if (_pendingModel != null) {
|
||||
sceneVers = _pendingModel.version;
|
||||
}
|
||||
|
||||
// issue a moveTo request
|
||||
log.info("Issuing moveTo(" + sceneId + ", " + sceneVers + ").");
|
||||
_sservice.moveTo(_wctx.getClient(), sceneId, sceneVers, this);
|
||||
// do the deed
|
||||
sendMoveRequest();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -201,7 +194,7 @@ public class SceneDirector extends BasicDirector
|
||||
return _pendingModel;
|
||||
}
|
||||
|
||||
// documentation inherited from interface SceneService_SceneMoveListener
|
||||
// from interface SceneService_SceneMoveListener
|
||||
public function moveSucceeded (placeId :int, config :PlaceConfig) :void
|
||||
{
|
||||
// our move request was successful, deal with subscribing to our new place object
|
||||
@@ -234,9 +227,9 @@ public class SceneDirector extends BasicDirector
|
||||
_scene = _fact.createScene(_model, config);
|
||||
}
|
||||
|
||||
// documentation inherited from interface SceneService_SceneMoveListener
|
||||
// from interface SceneService_SceneMoveListener
|
||||
public function moveSucceededWithUpdates (
|
||||
placeId :int, config :PlaceConfig, updates :Array) :void
|
||||
placeId :int, config :PlaceConfig, updates :TypedArray) :void
|
||||
{
|
||||
log.info("Got updates [placeId=" + placeId + ", config=" + config +
|
||||
", updates=" + updates + "].");
|
||||
@@ -289,7 +282,7 @@ public class SceneDirector extends BasicDirector
|
||||
moveSucceeded(placeId, config);
|
||||
}
|
||||
|
||||
// documentation inherited from interface SceneService-SceneMoveListener
|
||||
// from interface SceneService_SceneMoveListener
|
||||
public function moveSucceededWithScene (
|
||||
placeId :int, config :PlaceConfig, model :SceneModel) :void
|
||||
{
|
||||
@@ -306,6 +299,21 @@ public class SceneDirector extends BasicDirector
|
||||
moveSucceeded(placeId, config);
|
||||
}
|
||||
|
||||
// from interface SceneService_SceneMoveListener
|
||||
public function moveRequiresServerSwitch (hostname :String, ports :TypedArray) :void
|
||||
{
|
||||
// ship on over to the other server
|
||||
_wctx.getClient().moveToServer(hostname, ports, new ConfirmAdapter(
|
||||
function (reason :String) :void { // failed
|
||||
requestFailed(reason);
|
||||
},
|
||||
function () :void { // succeeded
|
||||
// resend our move request now that we're connected to the new server
|
||||
sendMoveRequest();
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public function requestFailed (reason :String) :void
|
||||
{
|
||||
@@ -391,6 +399,20 @@ public class SceneDirector extends BasicDirector
|
||||
}
|
||||
}
|
||||
|
||||
protected function sendMoveRequest () :void
|
||||
{
|
||||
// check the version of our cached copy of the scene to which we're requesting to move; if
|
||||
// we were unable to load it, assume a cached version of zero
|
||||
var sceneVers :int = 0;
|
||||
if (_pendingModel != null) {
|
||||
sceneVers = _pendingModel.version;
|
||||
}
|
||||
|
||||
// issue a moveTo request
|
||||
log.info("Issuing moveTo(" + _pendingSceneId + ", " + sceneVers + ").");
|
||||
_sservice.moveTo(_wctx.getClient(), _pendingSceneId, sceneVers, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears out our current scene information and releases the scene model for the loaded scene
|
||||
* back to the cache.
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
package com.threerings.whirled.client {
|
||||
|
||||
import flash.utils.ByteArray;
|
||||
import com.threerings.io.TypedArray;
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationService;
|
||||
|
||||
@@ -23,6 +23,7 @@ package com.threerings.whirled.client {
|
||||
|
||||
import flash.utils.ByteArray;
|
||||
import com.threerings.util.*; // for Float, Integer, etc.
|
||||
import com.threerings.io.TypedArray;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.presents.client.Client;
|
||||
@@ -39,6 +40,9 @@ import com.threerings.whirled.data.SceneUpdate;
|
||||
public interface SceneService_SceneMoveListener
|
||||
extends InvocationService_InvocationListener
|
||||
{
|
||||
// from Java SceneService_SceneMoveListener
|
||||
function moveRequiresServerSwitch (arg1 :String, arg2 :TypedArray /* of int */) :void
|
||||
|
||||
// from Java SceneService_SceneMoveListener
|
||||
function moveSucceeded (arg1 :int, arg2 :PlaceConfig) :void
|
||||
|
||||
@@ -46,6 +50,6 @@ public interface SceneService_SceneMoveListener
|
||||
function moveSucceededWithScene (arg1 :int, arg2 :PlaceConfig, arg3 :SceneModel) :void
|
||||
|
||||
// from Java SceneService_SceneMoveListener
|
||||
function moveSucceededWithUpdates (arg1 :int, arg2 :PlaceConfig, arg3 :Array) :void
|
||||
function moveSucceededWithUpdates (arg1 :int, arg2 :PlaceConfig, arg3 :TypedArray /* of class com.threerings.whirled.data.SceneUpdate */) :void
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ package com.threerings.whirled.data {
|
||||
|
||||
import flash.utils.ByteArray;
|
||||
import com.threerings.util.*; // for Float, Integer, etc.
|
||||
import com.threerings.io.TypedArray;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.presents.client.Client;
|
||||
|
||||
@@ -23,6 +23,7 @@ package com.threerings.whirled.data {
|
||||
|
||||
import flash.utils.ByteArray;
|
||||
import com.threerings.util.*; // for Float, Integer, etc.
|
||||
import com.threerings.io.TypedArray;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.presents.client.Client;
|
||||
@@ -38,19 +39,27 @@ import com.threerings.whirled.data.SceneUpdate;
|
||||
public class SceneMarshaller_SceneMoveMarshaller
|
||||
extends InvocationMarshaller_ListenerMarshaller
|
||||
{
|
||||
/** The method id used to dispatch {@link #moveRequiresServerSwitch} responses. */
|
||||
public static const MOVE_REQUIRES_SERVER_SWITCH :int = 1;
|
||||
|
||||
/** The method id used to dispatch {@link #moveSucceeded} responses. */
|
||||
public static const MOVE_SUCCEEDED :int = 1;
|
||||
public static const MOVE_SUCCEEDED :int = 2;
|
||||
|
||||
/** The method id used to dispatch {@link #moveSucceededWithScene} responses. */
|
||||
public static const MOVE_SUCCEEDED_WITH_SCENE :int = 2;
|
||||
public static const MOVE_SUCCEEDED_WITH_SCENE :int = 3;
|
||||
|
||||
/** The method id used to dispatch {@link #moveSucceededWithUpdates} responses. */
|
||||
public static const MOVE_SUCCEEDED_WITH_UPDATES :int = 3;
|
||||
public static const MOVE_SUCCEEDED_WITH_UPDATES :int = 4;
|
||||
|
||||
// from InvocationMarshaller_ListenerMarshaller
|
||||
override public function dispatchResponse (methodId :int, args :Array) :void
|
||||
{
|
||||
switch (methodId) {
|
||||
case MOVE_REQUIRES_SERVER_SWITCH:
|
||||
(listener as SceneService_SceneMoveListener).moveRequiresServerSwitch(
|
||||
(args[0] as String), (args[1] as TypedArray /* of int */));
|
||||
return;
|
||||
|
||||
case MOVE_SUCCEEDED:
|
||||
(listener as SceneService_SceneMoveListener).moveSucceeded(
|
||||
(args[0] as int), (args[1] as PlaceConfig));
|
||||
@@ -63,7 +72,7 @@ public class SceneMarshaller_SceneMoveMarshaller
|
||||
|
||||
case MOVE_SUCCEEDED_WITH_UPDATES:
|
||||
(listener as SceneService_SceneMoveListener).moveSucceededWithUpdates(
|
||||
(args[0] as int), (args[1] as PlaceConfig), (args[2] as Array));
|
||||
(args[0] as int), (args[1] as PlaceConfig), (args[2] as TypedArray /* of class com.threerings.whirled.data.SceneUpdate */));
|
||||
return;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user