Documented valid dobj types in DObject; implemented value marshaller which

can read and write all of the valid dobj types over the network; wired up
the attribute changed events to serialize and unserialize their values.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@35 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-06-12 02:57:30 +00:00
parent 89083f4708
commit c8b13e3bca
4 changed files with 550 additions and 8 deletions
@@ -1,5 +1,5 @@
//
// $Id: AttributeChangedEvent.java,v 1.4 2001/06/11 17:44:04 mdb Exp $
// $Id: AttributeChangedEvent.java,v 1.5 2001/06/12 02:57:30 mdb Exp $
package com.threerings.cocktail.cher.dobj;
@@ -8,7 +8,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;
import com.threerings.cocktail.cher.Log;
import com.threerings.cocktail.cher.dobj.io.ValueMarshaller;
/**
* An attribute changed event is dispatched when a single attribute of a
@@ -123,7 +123,7 @@ public class AttributeChangedEvent extends TypedEvent
{
super.writeTo(out);
out.writeUTF(_name);
// out.write...(_value);
ValueMarshaller.writeTo(out, _value);
}
public void readFrom (DataInputStream in)
@@ -131,7 +131,7 @@ public class AttributeChangedEvent extends TypedEvent
{
super.readFrom(in);
_name = in.readUTF();
// _value = in.read...
_value = ValueMarshaller.readFrom(in);
}
public String toString ()
@@ -1,5 +1,5 @@
//
// $Id: AttributesChangedEvent.java,v 1.3 2001/06/11 17:44:04 mdb Exp $
// $Id: AttributesChangedEvent.java,v 1.4 2001/06/12 02:57:30 mdb Exp $
package com.threerings.cocktail.cher.dobj;
@@ -7,6 +7,8 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import com.threerings.cocktail.cher.dobj.io.ValueMarshaller;
/**
* An attribute<em>s</em> changed event is dispatched when multiple
* attributes of a distributed object have been changed in a single
@@ -171,7 +173,7 @@ public class AttributesChangedEvent extends TypedEvent
out.writeInt(_count);
for (int i = 0; i < _count; i++) {
out.writeUTF(_names[i]);
// out.write...(_values[i]);
ValueMarshaller.writeTo(out, _values[i]);
}
}
@@ -184,7 +186,7 @@ public class AttributesChangedEvent extends TypedEvent
_values = new Object[_count];
for (int i = 0; i < _count; i++) {
_names[i] = in.readUTF();
// _values[i] = ...
_values[i] = ValueMarshaller.readFrom(in);
}
}
@@ -1,5 +1,5 @@
//
// $Id: DObject.java,v 1.9 2001/06/09 23:39:04 mdb Exp $
// $Id: DObject.java,v 1.10 2001/06/12 02:57:30 mdb Exp $
package com.threerings.cocktail.cher.dobj;
@@ -70,6 +70,15 @@ import java.util.ArrayList;
*
* These method calls on the actual distributed object will result in the
* proper attribute change events being generated and dispatched.
*
* <p> Note that distributed object fields can only be of a limited set of
* supported types. These types are:
*
* <code><pre>
* byte, short, int, long, float, double
* Byte, Short, Integer, Long, Float, Double, String
* byte[], short[], int[], long[], float[], double[], String[]
* </pre></code>
*/
public class DObject
{