More progress.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3861 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
package com.threerings.presents.dobj {
|
||||
|
||||
import flash.util.StringBuilder;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
/**
|
||||
* A message event is used to dispatch a message to all subscribers of a
|
||||
* distributed object without actually changing any of the fields of the
|
||||
* object. A message has a name, by which different subscribers of the
|
||||
* same object can distinguish their different messages, and an array of
|
||||
* arguments by which any contents of the message can be delivered.
|
||||
*
|
||||
* @see DObjectManager#postEvent
|
||||
*/
|
||||
public class MessageEvent extends NamedEvent
|
||||
{
|
||||
/**
|
||||
* Constructs a new message event on the specified target object with
|
||||
* the supplied name and arguments.
|
||||
*
|
||||
* @param targetOid the object id of the object whose attribute has
|
||||
* changed.
|
||||
* @param name the name of the message event.
|
||||
* @param args the arguments for this message. This array should
|
||||
* contain only values of valid distributed object types.
|
||||
*/
|
||||
public function MessageEvent (targetOid :int, name :String, args :Array)
|
||||
{
|
||||
super(targetOid, name);
|
||||
_args = args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the arguments to this message.
|
||||
*/
|
||||
public function getArgs () :Array
|
||||
{
|
||||
return _args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the arguments associated with this message event.
|
||||
* <em>Note:</em> this should only be called on events that have not
|
||||
* yet been dispatched into the distributed object system.
|
||||
*/
|
||||
public function setArgs (args :Array) :void
|
||||
{
|
||||
_args = 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 :*) :void
|
||||
{
|
||||
if (listener is MessageListener) {
|
||||
listener.messageReceived(this);
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
protected override function toString (buf :StringBuilder) :void
|
||||
{
|
||||
buf.append("MSG:");
|
||||
super.toString(buf);
|
||||
buf.append(", args=", _args);
|
||||
}
|
||||
|
||||
protected var _args :Array;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user