More work on things.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3900 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-03-01 23:52:52 +00:00
parent 679133091b
commit 740e00c731
22 changed files with 684 additions and 19 deletions
@@ -68,7 +68,7 @@ public class AttributeChangedEvent extends NamedEvent
}
// documentation inherited
internal override function notifyListener (listener :Object) :void
protected override function notifyListener (listener :Object) :void
{
if (listener is AttributeChangeListener) {
listener.attributeChanged(this);
+34 -1
View File
@@ -40,6 +40,36 @@ public /* abstract */ class DEvent
return false;
}
/**
* Returns the object id of the client that generated this event. If
* the event was generated by the server, the value returned will be
* -1. This is not valid on the client, it will return -1 for all
* events there (it is primarily provided to allow for event-level
* access control).
*/
public function getSourceOid () :int
{
return _soid;
}
/**
* Do not call this method. Sets the source oid of the client that
* generated this event. It is automatically called by the client
* management code when a client forwards an event to the server.
*/
public function setSourceOid (sourceOid :int) :void
{
_soid = sourceOid;
}
/**
* We want to make the notifyListener method visible to DObject.
*/
internal function friendNotifyListener (listener :Object) :void
{
notifyListener(listener);
}
/**
* Events with associated listener interfaces should implement this
* function and notify the supplied listener if it implements their
@@ -47,7 +77,7 @@ public /* abstract */ class DEvent
* AttributeChangedEvent} will notify listeners that implement {@link
* AttributeChangeListener}.
*/
internal function notifyListener (listener :Object) :void
protected function notifyListener (listener :Object) :void
{
// the default is to do nothing
}
@@ -89,6 +119,9 @@ public /* abstract */ class DEvent
/** The oid of the object that is the target of this event. */
protected var _toid :int;
/** The oid of the client that generated this event. */
protected var _soid :int = -1;
protected static const UNSET_OLD_ENTRY :DSetEntry = new DummyEntry();
}
}
@@ -83,7 +83,7 @@ public class DObject // extends EventDispatcher
for (var ii :int = 0; ii < _listeners.length; ii++) {
var listener :Object = _listeners.getItemAt(ii);
try {
event.notifyListener(listener);
event.friendNotifyListener(listener);
if (listener is EventListener) {
listener.eventReceived(event);
@@ -95,7 +95,7 @@ public class ElementUpdatedEvent extends NamedEvent
}
// documentation inherited
internal override function notifyListener (listener :Object) :void
protected override function notifyListener (listener :Object) :void
{
if (listener is ElementUpdateListener) {
listener.elementUpdated(this);
@@ -55,7 +55,7 @@ public class EntryAddedEvent extends NamedEvent
}
// documentation inherited
internal override function notifyListener (listener :Object) :void
protected override function notifyListener (listener :Object) :void
{
if (listener is SetListener) {
listener.entryAdded(this);
@@ -75,7 +75,7 @@ public class EntryRemovedEvent extends NamedEvent
}
// documentation inherited
internal override function notifyListener (listener :Object) :void
protected override function notifyListener (listener :Object) :void
{
if (listener is SetListener) {
listener.entryRemoved(this);
@@ -73,7 +73,7 @@ public class EntryUpdatedEvent extends NamedEvent
}
// documentation inherited
internal override function notifyListener (listener :Object) :void
protected override function notifyListener (listener :Object) :void
{
if (listener is SetListener) {
listener.entryUpdated(this);
@@ -0,0 +1,134 @@
//
// $Id: InvocationRequestEvent.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.dobj {
import flash.util.StringBuilder;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* Used to dispatch an invocation request from the client to the server.
*
* @see DObjectManager#postEvent
*/
public class InvocationRequestEvent extends DEvent
{
/**
* Constructs a new invocation request event on the specified target
* object with the supplied code, method and arguments.
*
* @param targetOid the object id of the object on which the event is
* to be dispatched.
* @param invCode the invocation provider identification code.
* @param methodId the id of the method to be invoked.
* @param args the arguments for the method. This array should contain
* only values of valid distributed object types.
*/
public function InvocationRequestEvent (
targetOid :int, invCode :int, methodId :int, args :Array)
{
super(targetOid);
_invCode = invCode;
_methodId = methodId;
_args = args;
}
/**
* Returns the invocation code associated with this request.
*/
public function getInvCode () :int
{
return _invCode;
}
/**
* Returns the id of the method associated with this request.
*/
public function getMethodId () :int
{
return _methodId;
}
/**
* Returns the arguments associated with this request.
*/
public function getArgs () :Array
{
return _args;
}
/**
* Applies this attribute change to the object.
*/
public override function applyToObject (target :DObject) :Boolean
//throws ObjectAccessException
{
// nothing to do here
return true;
}
// documentation inherited
protected override function notifyListener (listener :Object) :void
{
// nothing to do here
}
// documentation inherited
protected override function toStringBuf (buf :StringBuilder) :void
{
buf.append("IREQ:");
super.toStringBuf(buf);
buf.append(", code=", _invCode);
buf.append(", methodId=", _methodId);
buf.append(", args=", _args);
}
// documentation inherited from interface Streamable
public override function writeObject (out :ObjectOutputStream) :void
{
super.writeObject(out);
out.writeInt(_invCode);
out.writeByte(_methodId);
out.writeObject(_args);
}
// documentation inherited from interface Streamable
public override function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
_invCode = ins.readInt();
_methodId = ins.readByte();
_args = (ins.readObject() as Array);
}
/** The code identifying which invocation provider to which this
* request is directed. */
protected var _invCode :int;
/** The id of the method being invoked. */
protected var _methodId :int;
/** The arguments to the method being invoked. */
protected var _args :Array;
}
}
@@ -0,0 +1,133 @@
//
// $Id: InvocationResponseEvent.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.dobj {
import flash.util.StringBuilder;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* Used to dispatch an invocation response from the server to the client.
*
* @see DObjectManager#postEvent
*/
public class InvocationResponseEvent extends DEvent
{
/**
* Constructs a new invocation response event on the specified target
* object with the supplied code, method and arguments.
*
* @param targetOid the object id of the object on which the event is
* to be dispatched.
* @param requestId the id of the request to which we are responding.
* @param methodId the method to be invoked.
* @param args the arguments for the method. This array should contain
* only values of valid distributed object types.
*/
public function InvocationResponseEvent (
targetOid :int, requestId :int, methodId :int, args :Array)
{
super(targetOid);
_requestId = requestId;
_methodId = methodId;
_args = args;
}
/**
* Returns the invocation request id associated with this response.
*/
public function getRequestId () :int
{
return _requestId;
}
/**
* Returns the method associated with this response.
*/
public function getMethodId () :int
{
return _methodId;
}
/**
* Returns the arguments associated with this response.
*/
public function getArgs () :Array
{
return _args;
}
/**
* Applies this attribute change to the object.
*/
public override function applyToObject (target :DObject) :Boolean
//throws ObjectAccessException
{
// nothing to do here
return true;
}
// documentation inherited
protected override function notifyListener (listener :Object) :void
{
// nothing to do here
}
// documentation inherited
protected override function toStringBuf (buf :StringBuilder) :void
{
buf.append("IRSP:");
super.toStringBuf(buf);
buf.append(", reqid=", _requestId);
buf.append(", methodId=", _methodId);
buf.append(", args=", _args);
}
// documentation inherited
public override function writeObject (out :ObjectOutputStream) :void
{
super.writeObject(out);
out.writeShort(_requestId);
out.writeByte(_methodId);
out.writeObject(_args);
}
// documentation inherited
public override function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
_requestId = ins.readShort();
_methodId = ins.readByte();
_args = (ins.readObject() as Array);
}
/** The id of the request with which this response is associated. */
protected var _requestId :int;
/** The id of the method being invoked. */
protected var _methodId :int;
/** The arguments to the method being invoked. */
protected var _args :Array;
}
}
@@ -61,7 +61,7 @@ public class MessageEvent extends NamedEvent
}
// documentation inherited
internal override function notifyListener (listener :Object) :void
protected override function notifyListener (listener :Object) :void
{
if (listener is MessageListener) {
listener.messageReceived(this);
@@ -51,7 +51,7 @@ public class ObjectAddedEvent extends NamedEvent
}
// documentation inherited
internal override function notifyListener (listener :Object) :void
protected override function notifyListener (listener :Object) :void
{
if (listener is OidListListener) {
listener.objectAdded(this);
@@ -53,7 +53,7 @@ public class ObjectDestroyedEvent extends DEvent
}
// documentation inherited
internal override function notifyListener (listener :Object) :void
protected override function notifyListener (listener :Object) :void
{
if (listener is ObjectDeathListener) {
listener.objectDestroyed(this);
@@ -74,7 +74,7 @@ public class ObjectRemovedEvent extends NamedEvent
}
// documentation inherited
internal override function notifyListener (listener :Object) :void
protected override function notifyListener (listener :Object) :void
{
if (listener is OidListListener) {
listener.objectRemoved(this);