Got compiling working under Linux, now correcting various errors.

Checkpoint.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3866 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-02-20 02:38:56 +00:00
parent f8c8f6e983
commit 7a80c5cb43
41 changed files with 453 additions and 141 deletions
@@ -1,5 +1,7 @@
package com.threerings.presents.client {
import flash.util.trace;
import flash.events.EventDispatcher;
import flash.events.TimerEvent;
import flash.util.Timer;
@@ -65,6 +67,11 @@ public class Client extends EventDispatcher
return _authData;
}
public function setAuthResponseData (data :AuthResponseData) :void
{
_authData = data;
}
public function getDObjectManager () :DObjectManager
{
return _omgr;
@@ -216,7 +223,7 @@ public class Client extends EventDispatcher
notifyObservers(ClientEvent.CLIENT_OBJECT_CHANGED);
}
protected function cleanup (logonError :Error) :void
internal function cleanup (logonError :Error) :void
{
// clear out our references
_comm = null;
@@ -238,7 +245,7 @@ public class Client extends EventDispatcher
/**
* Called by the omgr when we receive a pong packet.
*/
protected function gotPong (pong :PongResponse) :void
public function gotPong (pong :PongResponse) :void
{
// TODO: compute time delta bowl-shit
}
@@ -247,7 +254,7 @@ public class Client extends EventDispatcher
* Convenience method to dispatch a client event to any listeners
* and return the result of dispatchEvent.
*/
protected function notifyObservers (evtCode :String, cause :Error = null)
public function notifyObservers (evtCode :String, cause :Error = null)
:Boolean
{
return dispatchEvent(new ClientEvent(evtCode, this, cause));
@@ -24,12 +24,27 @@ package com.threerings.presents.client {
import flash.events.TimerEvent;
import flash.util.Timer;
import flash.util.trace;
import mx.collections.IList;
import com.threerings.util.ClassUtil;
import com.threerings.util.SimpleMap;
import com.threerings.presents.dobj.DEvent;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.dobj.ObjectDestroyedEvent;
import com.threerings.presents.dobj.Subscriber;
import com.threerings.presents.net.BootstrapNotification;
import com.threerings.presents.net.EventNotification;
import com.threerings.presents.net.DownstreamMessage;
import com.threerings.presents.net.FailureResponse;
import com.threerings.presents.net.ForwardEventRequest;
import com.threerings.presents.net.ObjectResponse;
import com.threerings.presents.net.PongResponse;
import com.threerings.presents.net.UnsubscribeResponse;
/**
* The client distributed object manager manages a set of proxy objects
@@ -202,7 +217,7 @@ public class ClientDObjectMgr
notifyFailure(oid);
} else if (obj is PongResponse) {
_client.gotPong(obj);
_client.gotPong(obj as PongResponse);
} else if (obj is ObjectAction) {
var act :ObjectAction = (obj as ObjectAction);
@@ -223,7 +238,7 @@ public class ClientDObjectMgr
// if this is a compound event, we need to process its contained
// events in order
if (event is CompoundEvent) {
var events :IList = event.getEvents();
var events :IList = (event as CompoundEvent).getEvents();
var ecount :int = events.length;
for (var ii :int = 0; ii < ecount; ii++) {
dispatchEvent(events.getItemAt(ii));
@@ -404,7 +419,7 @@ public class ClientDObjectMgr
var rec :FlushRecord = _flushes[oid];
if (rec.expire <= now) {
_flushes[oid] = undefined;
flushObject(rec.object);
flushObject(rec.obj);
}
}
}
@@ -436,7 +451,7 @@ public class ClientDObjectMgr
/** Flushes objects every now and again. */
protected var _flushInterval :Timer;
protected var _flushInterval :Timer;
protected var _actionInterval :Timer;
/** Flush expired objects every 30 seconds. */
protected static const FLUSH_INTERVAL :Number = 30 * 1000;
@@ -447,27 +462,27 @@ public class ClientDObjectMgr
* The object action is used to queue up a subscribe or unsubscribe
* request.
*/
protected class ObjectAction
class ObjectAction
{
public var oid :int;
public var target :Subscriber;
public var target :com.threerings.presents.dobj.Subscriber;
public var subscribe :Boolean;
public function ObjectAction (
oid :int, target :Subscriber, subscribe :Boolean)
oid :int, target :com.threerings.presents.dobj.Subscriber, subscribe :Boolean)
{
this.oid = oid;
this.target = target;
this.subscribe = subscribe;
}
public override function toString () :String
public function toString () :String
{
return "oid=" + oid + ", target=" + target + ", subscribe=" + subscribe;
}
}
protected class PendingRequest
class PendingRequest
{
public var oid :int;
public var targets :Array = new Array();
@@ -477,24 +492,24 @@ protected class PendingRequest
this.oid = oid;
}
public function addTarget (target :Subscriber) :void
public function addTarget (target :com.threerings.presents.dobj.Subscriber) :void
{
targets.push(target);
}
}
/** Used to manage pending object flushes. */
protected class FlushRecord
class FlushRecord
{
/** The object to be flushed. */
public var obj :DObject;
public var obj :com.threerings.presents.dobj.DObject;
/** The time at which we flush it. */
public var expire :Number;
public function FlushRecord (obj :DObject, expire :Number)
public function FlushRecord (obj :com.threerings.presents.dobj.DObject, expire :Number)
{
this.object = object;
this.obj = obj;
this.expire = expire;
}
}
@@ -1,5 +1,10 @@
package com.threerings.presents.client {
import flash.util.trace;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.net.Socket;
import flash.util.ByteArray;
@@ -10,6 +15,13 @@ import com.threerings.io.FrameReader;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
import com.threerings.presents.net.AuthRequest;
import com.threerings.presents.net.AuthResponse;
import com.threerings.presents.net.AuthResponseData;
import com.threerings.presents.net.DownstreamMessage;
import com.threerings.presents.net.LogoffRequest;
import com.threerings.presents.net.UpstreamMessage;
public class Communicator
{
public function Communicator (client :Client)
@@ -50,6 +62,11 @@ public class Communicator
shutdown(null);
}
public function postMessage (msg :UpstreamMessage) :void
{
sendMessage(msg); // send it now: we have no out queue (TODO?)
}
protected function shutdown (logonError :Error) :void
{
if (_socket != null) {
@@ -132,7 +149,7 @@ public class Communicator
// logon success
_omgr = new ClientDObjectMgr(this, _client);
_client._authData = data;
_client.setAuthResponseData(data);
}
/**
@@ -160,17 +177,18 @@ public class Communicator
*/
protected function socketClosed (event :Event) :void
{
_client.notifyObserver(ClientEvent.CLIENT_CONNECTION_FAILED);
_client.notifyObservers(ClientEvent.CLIENT_CONNECTION_FAILED);
shutdown(null);
}
protected var _client :Client;
protected var _omgr :ClientDObjectManager;
protected var _omgr :ClientDObjectMgr;
protected var _outBuffer :ByteArray;
protected var _outStream :ObjectOutputStream;
protected var _inStream :ObjectInputStream;
protected var _frameReader :FrameReader;
protected var _socket :Socket;
@@ -1,7 +1,11 @@
package com.threerings.presents.client {
import flash.util.trace;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.data.ClientObject;
public class InvocationDirector
{
public function init (omgr :DObjectManager, cloid :int, client :Client) :void
@@ -0,0 +1,129 @@
//
// $Id: InvocationService.java 3099 2004-08-27 02:21:06Z mdb $
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.presents.client {
/**
* Serves as the base interface for invocation services. An invocation
* service can be defined by extending this interface and defining service
* methods, as well as response listeners (which must extend {@link
* InvocationListener}). For example:
*
* <pre>
* public interface LocationService extends InvocationService
* {
*
* // Used to communicate responses to moveTo() requests.
* public interface MoveListener extends InvocationListener
* {
* // Called in response to a successful moveTo() request.
* public void moveSucceeded (PlaceConfig config);
* }
*
* // Requests that this client's body be moved to the specified
* // location.
* //
* // @param placeId the object id of the place object to which the
* // body should be moved.
* // @param listener the listener that will be informed of success or
* // failure.
* public void moveTo (int placeId, MoveListener listener);
* }
* </pre>
*
* From this interface, a <code>LocationProvider</code> interface will be
* generated which should be implemented by whatever server entity that
* will actually provide the server side of this invocation service. That
* provider interface would look like the following:
*
* <pre>
* public interface LocationProvider extends InvocationProvider
* {
* // Requests that this client's body be moved to the specified
* // location.
* //
* // @param caller the client object of the client that invoked this
* // remotely callable method.
* // @param placeId the object id of the place object to which the
* // body should be moved.
* // @param listener the listener that should be informed of success
* // or failure.
* public void moveTo (ClientObject caller, int placeId,
* MoveListener listener)
* throws InvocationException;
* }
* </pre>
*/
public interface InvocationService
{
/**
* Invocation service methods that require a response should take a
* listener argument that can be notified of request success or
* failure. The listener argument should extend this interface so that
* generic failure can be reported in all cases. For example:
*
* <pre>
* // Used to communicate responses to <code>moveTo</code> requests.
* public interface MoveListener extends InvocationListener
* {
* // Called in response to a successful <code>moveTo</code>
* // request.
* public void moveSucceeded (PlaceConfig config);
* }
* </pre>
*/
// public static interface InvocationListener
// {
/**
* Called to report request failure. If the invocation services
* system detects failure of any kind, it will report it via this
* callback. Particular services may also make use of this
* callback to report failures of their own, or they may opt to
* define more specific failure callbacks.
*/
// public void requestFailed (String cause);
// }
/**
* Extends the {@link InvocationListener} with a basic success
* callback.
*/
// public static interface ConfirmListener extends InvocationListener
// {
/**
* Indicates that the request was successfully processed.
*/
// public void requestProcessed ();
// }
/**
* Extends the {@link InvocationListener} with a basic success
* callback that delivers a result object.
*/
// public static interface ResultListener extends InvocationListener
// {
/**
* Indicates that the request was successfully processed.
*/
// public void requestProcessed (Object result);
// }
}
}