I changed a few things and suddenly the inaccessable method works again.
Boy, fun. I guess I'm embracing the 'adapter' construct for emulating anonymous classes, but I wish I wasn't. I have half an idea to start over from scratch and write a very actionscripty dobj/services/receiver system that ends up looking very different on the client but still speaks to the server in the same way. Probably things would just get more and more complex until I was back here. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3983 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -328,7 +328,3 @@ ActionScript
|
||||
- add code to verify the object's functions against describeType calls..
|
||||
(would need to iterate on types because describeType only finds methods
|
||||
in the terminal interface. Only # of args can be checked)
|
||||
|
||||
- actionscript problems
|
||||
- helper classes go outside the package
|
||||
- each cast is broken in one way or another
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.threerings.presents.client.ClientEvent;
|
||||
import com.threerings.presents.dobj.DObject;
|
||||
import com.threerings.presents.dobj.ObjectAccessError;
|
||||
import com.threerings.presents.dobj.Subscriber;
|
||||
import com.threerings.presents.dobj.SubscriberAdapter;
|
||||
|
||||
import com.threerings.crowd.Log;
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
@@ -163,35 +164,32 @@ public class LocationDirector extends BasicDirector
|
||||
// make a note of our pending place id
|
||||
_pendingPlaceId = placeId;
|
||||
|
||||
var listener :MoveListenerProxy = new MoveListenerProxy();
|
||||
// documentation inherited from interface MoveListener
|
||||
var success :Function = function (config :PlaceConfig) :void {
|
||||
// handle the successful move
|
||||
didMoveTo(_pendingPlaceId, config);
|
||||
|
||||
// and clear out the tracked pending oid
|
||||
_pendingPlaceId = -1;
|
||||
};
|
||||
|
||||
// documentation inherited from interface MoveListener
|
||||
// listener.moveSucceeded = function (config :PlaceConfig) :void
|
||||
// {
|
||||
// // handle the successful move
|
||||
// didMoveTo(_pendingPlaceId, config);
|
||||
//
|
||||
// // and clear out the tracked pending oid
|
||||
// _pendingPlaceId = -1;
|
||||
// };
|
||||
var failure :Function = function (reason :String) :void {
|
||||
// clear out our pending request oid
|
||||
var placeId :int = _pendingPlaceId;
|
||||
_pendingPlaceId = -1;
|
||||
|
||||
// documentation inherited from interface
|
||||
// listener.requestFailed = function (reason :String) :void
|
||||
// {
|
||||
// // clear out our pending request oid
|
||||
// var placeId :int = _pendingPlaceId;
|
||||
// _pendingPlaceId = -1;
|
||||
//
|
||||
// Log.info("moveTo failed [pid=" + placeId +
|
||||
// ", reason=" + reason + "].");
|
||||
//
|
||||
// // let our observers know that something has gone horribly awry
|
||||
// notifyFailure(placeId, reason);
|
||||
// };
|
||||
Log.info("moveTo failed [pid=" + placeId +
|
||||
", reason=" + reason + "].");
|
||||
|
||||
// let our observers know that something has gone horribly awry
|
||||
notifyFailure(placeId, reason);
|
||||
};
|
||||
|
||||
// issue a moveTo request
|
||||
Log.info("Issuing moveTo(" + placeId + ").");
|
||||
_lservice.moveTo(_cctx.getClient(), placeId, listener);
|
||||
_lservice.moveTo(_cctx.getClient(), placeId,
|
||||
new MoveAdapter(success, failure));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -407,22 +405,20 @@ public class LocationDirector extends BasicDirector
|
||||
{
|
||||
super.clientDidLogon(event);
|
||||
|
||||
// TODO: Work out new anonyclass construct
|
||||
// var sub :SubscriberProxy = new SubscriberProxy();
|
||||
var sub :Object = new Object();
|
||||
sub.objectAvailable = function (object :DObject) :void {
|
||||
var success :Function = function (object :DObject) :void {
|
||||
gotBodyObject(object as BodyObject);
|
||||
};
|
||||
sub.requestFailed = function (oid :int, cause :ObjectAccessError) :void {
|
||||
var failure :Function = function (
|
||||
oid :int, cause :ObjectAccessError) :void {
|
||||
Log.warning("Location director unable to fetch body " +
|
||||
"object; all has gone horribly wrong" +
|
||||
"[cause=" + cause + "].");
|
||||
};
|
||||
sub.objectAvailable(null);
|
||||
|
||||
var client :Client = event.getClient();
|
||||
var cloid :int = client.getClientOid();
|
||||
client.getDObjectManager().subscribeToObject(cloid, null);
|
||||
client.getDObjectManager().subscribeToObject(cloid,
|
||||
new SubscriberAdapter(success, failure));
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
@@ -612,30 +608,3 @@ public class LocationDirector extends BasicDirector
|
||||
protected static const STALE_REQUEST_DURATION :int = 60 * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
import com.threerings.presents.dobj.DObject;
|
||||
import com.threerings.presents.dobj.ObjectAccessError;
|
||||
import com.threerings.presents.dobj.Subscriber;
|
||||
|
||||
import com.threerings.crowd.client.MoveListener;
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
|
||||
dynamic class SubscriberProxy implements Subscriber
|
||||
{
|
||||
public function objectAvailable (obj :DObject) :void
|
||||
{
|
||||
}
|
||||
public function requestFailed (oid :int, cause :ObjectAccessError) :void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
dynamic class MoveListenerProxy implements MoveListener
|
||||
{
|
||||
public function moveSucceeded (config :PlaceConfig) :void
|
||||
{
|
||||
}
|
||||
public function requestFailed (cause :String) :void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.threerings.crowd.client {
|
||||
|
||||
import com.threerings.presents.client.InvocationAdapter;
|
||||
|
||||
import com.threerings.crowd.data.PlaceConfig;
|
||||
|
||||
public class MoveAdapter extends InvocationAdapter
|
||||
implements MoveListener
|
||||
{
|
||||
public function MoveAdapter (success :Function, failure :Function)
|
||||
{
|
||||
super(failure);
|
||||
_success = success;
|
||||
}
|
||||
|
||||
// documentation inherited from interface MoveListener
|
||||
public function moveSucceeded (config :PlaceConfig) :void
|
||||
{
|
||||
_success(config);
|
||||
}
|
||||
|
||||
protected var _success :Function;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import com.threerings.util.Name;
|
||||
import com.threerings.presents.Log;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.dobj.DSet;
|
||||
import com.threerings.presents.dobj.QSet;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.net.UsernamePasswordCreds;
|
||||
|
||||
import com.threerings.presents.dobj.DObjectManager;
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.threerings.presents.client {
|
||||
|
||||
import com.threerings.presents.client.InvocationDirector;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.dobj.DObject;
|
||||
import com.threerings.presents.dobj.ObjectAccessError;
|
||||
import com.threerings.presents.dobj.Subscriber;
|
||||
import com.threerings.presents.Log;
|
||||
|
||||
/**
|
||||
* This class is used by the InvocationDirector to subscribe
|
||||
* to the client object.
|
||||
*/
|
||||
public class ClientSubscriber implements Subscriber
|
||||
{
|
||||
public function ClientSubscriber (invdir :InvocationDirector)
|
||||
{
|
||||
_invdir = invdir;
|
||||
}
|
||||
|
||||
// documentation inherited from interface Subscriber
|
||||
public function objectAvailable (obj :DObject) :void
|
||||
{
|
||||
_invdir.gotClientObject(obj as ClientObject);
|
||||
}
|
||||
|
||||
// documentation inherited from interface Subscriber
|
||||
public function requestFailed (oid :int, cause :ObjectAccessError) :void
|
||||
{
|
||||
_invdir.gotClientObjectFailed(oid, cause);
|
||||
}
|
||||
|
||||
protected var _invdir :InvocationDirector;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import com.threerings.presents.dobj.InvocationNotificationEvent;
|
||||
import com.threerings.presents.dobj.InvocationRequestEvent;
|
||||
import com.threerings.presents.dobj.ObjectAccessError;
|
||||
import com.threerings.presents.dobj.Subscriber;
|
||||
import com.threerings.presents.dobj.SubscriberAdapter;
|
||||
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
|
||||
@@ -35,7 +36,8 @@ public class InvocationDirector
|
||||
_omgr = omgr;
|
||||
_client = client;
|
||||
|
||||
_omgr.subscribeToObject(cloid, new ClientSubscriber(this));
|
||||
_omgr.subscribeToObject(cloid, new SubscriberAdapter(
|
||||
this.gotClientObject, this.gotClientObjectFailed));
|
||||
}
|
||||
|
||||
public function cleanup () :void
|
||||
@@ -306,7 +308,7 @@ public class InvocationDirector
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the ClientSubscriber helper class when the client object
|
||||
* Called by the ClientObject SubscriberAdapter when the client object
|
||||
* has been returned by the server.
|
||||
*/
|
||||
internal function gotClientObject (clobj :ClientObject) :void
|
||||
@@ -320,7 +322,7 @@ public class InvocationDirector
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the ClientSubscriber helper class when it fails.
|
||||
* Called by the ClientObject SubscriberAdapter when it fails.
|
||||
*/
|
||||
internal function gotClientObjectFailed (
|
||||
oid :int, cause :ObjectAccessError) :void
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.threerings.presents.dobj {
|
||||
|
||||
public class SubscriberAdapter
|
||||
implements Subscriber
|
||||
{
|
||||
public function SubscriberAdapter (success :Function, failure :Function)
|
||||
{
|
||||
_success = success;
|
||||
_failure = failure;
|
||||
}
|
||||
|
||||
// documentation inherited from interface Subscriber
|
||||
public function objectAvailable (obj :DObject) :void
|
||||
{
|
||||
_success(obj);
|
||||
}
|
||||
|
||||
// documentation inherited from interface Subscriber
|
||||
public function requestFailed (oid :int, cause :ObjectAccessError) :void
|
||||
{
|
||||
_failure(oid, cause);
|
||||
}
|
||||
|
||||
protected var _success :Function;
|
||||
protected var _failure :Function;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user