From 70a79f48e961fe589dd88039537016b6c0fc5a05 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 20 Dec 2002 23:28:24 +0000 Subject: [PATCH] Bye bye to all the hand-serialization code. Yay! git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2077 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/presents/net/AuthRequest.java | 24 +------------------ .../threerings/presents/net/AuthResponse.java | 22 +---------------- .../presents/net/BootstrapNotification.java | 22 +---------------- .../threerings/presents/net/Credentials.java | 22 +---------------- .../presents/net/DownstreamMessage.java | 20 +--------------- .../presents/net/EventNotification.java | 22 +---------------- .../presents/net/FailureResponse.java | 22 +---------------- .../presents/net/ForwardEventRequest.java | 22 +---------------- .../presents/net/ObjectResponse.java | 22 +---------------- .../threerings/presents/net/PingRequest.java | 14 +++++------ .../threerings/presents/net/PongResponse.java | 18 +++++--------- .../presents/net/SubscribeRequest.java | 22 +---------------- .../presents/net/UnsubscribeRequest.java | 22 +---------------- .../presents/net/UpstreamMessage.java | 20 +--------------- .../presents/net/UsernamePasswordCreds.java | 22 +---------------- 15 files changed, 26 insertions(+), 290 deletions(-) diff --git a/src/java/com/threerings/presents/net/AuthRequest.java b/src/java/com/threerings/presents/net/AuthRequest.java index dd0710cc5..fe5959637 100644 --- a/src/java/com/threerings/presents/net/AuthRequest.java +++ b/src/java/com/threerings/presents/net/AuthRequest.java @@ -1,5 +1,5 @@ // -// $Id: AuthRequest.java,v 1.9 2002/10/31 18:44:34 mdb Exp $ +// $Id: AuthRequest.java,v 1.10 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -45,28 +45,6 @@ public class AuthRequest extends UpstreamMessage return _version; } - /** - * Writes our custom streamable fields. - */ - public void writeObject (ObjectOutputStream out) - throws IOException - { - super.writeObject(out); - out.writeObject(_creds); - out.writeUTF(_version); - } - - /** - * Reads our custom streamable fields. - */ - public void readObject (ObjectInputStream in) - throws IOException, ClassNotFoundException - { - super.readObject(in); - _creds = (Credentials)in.readObject(); - _version = in.readUTF(); - } - /** * Generates a string representation of this instance. */ diff --git a/src/java/com/threerings/presents/net/AuthResponse.java b/src/java/com/threerings/presents/net/AuthResponse.java index b05e9772f..594513dc6 100644 --- a/src/java/com/threerings/presents/net/AuthResponse.java +++ b/src/java/com/threerings/presents/net/AuthResponse.java @@ -1,5 +1,5 @@ // -// $Id: AuthResponse.java,v 1.12 2002/07/23 05:52:48 mdb Exp $ +// $Id: AuthResponse.java,v 1.13 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -38,26 +38,6 @@ public class AuthResponse extends DownstreamMessage return _data; } - /** - * Writes our custom streamable fields. - */ - public void writeObject (ObjectOutputStream out) - throws IOException - { - super.writeObject(out); - out.writeObject(_data); - } - - /** - * Reads our custom streamable fields. - */ - public void readObject (ObjectInputStream in) - throws IOException, ClassNotFoundException - { - super.readObject(in); - _data = (AuthResponseData)in.readObject(); - } - public String toString () { return "[type=ARSP, msgid=" + messageId + ", data=" + _data + "]"; diff --git a/src/java/com/threerings/presents/net/BootstrapNotification.java b/src/java/com/threerings/presents/net/BootstrapNotification.java index f31d6a9c3..b12457f88 100644 --- a/src/java/com/threerings/presents/net/BootstrapNotification.java +++ b/src/java/com/threerings/presents/net/BootstrapNotification.java @@ -1,5 +1,5 @@ // -// $Id: BootstrapNotification.java,v 1.4 2002/07/23 05:52:48 mdb Exp $ +// $Id: BootstrapNotification.java,v 1.5 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -39,26 +39,6 @@ public class BootstrapNotification extends DownstreamMessage return _data; } - /** - * Writes our custom streamable fields. - */ - public void writeObject (ObjectOutputStream out) - throws IOException - { - super.writeObject(out); - out.writeObject(_data); - } - - /** - * Reads our custom streamable fields. - */ - public void readObject (ObjectInputStream in) - throws IOException, ClassNotFoundException - { - super.readObject(in); - _data = (BootstrapData)in.readObject(); - } - public String toString () { return "[type=BOOT, msgid=" + messageId + ", data=" + _data + "]"; diff --git a/src/java/com/threerings/presents/net/Credentials.java b/src/java/com/threerings/presents/net/Credentials.java index 6ec54c88a..76bde14b0 100644 --- a/src/java/com/threerings/presents/net/Credentials.java +++ b/src/java/com/threerings/presents/net/Credentials.java @@ -1,5 +1,5 @@ // -// $Id: Credentials.java,v 1.9 2002/09/18 21:58:30 mdb Exp $ +// $Id: Credentials.java,v 1.10 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -46,26 +46,6 @@ public abstract class Credentials implements Streamable return _username; } - /** - * Writes our custom streamable fields. - */ - public void writeObject (ObjectOutputStream out) - throws IOException - { - out.defaultWriteObject(); - out.writeUTF(_username); - } - - /** - * Reads our custom streamable fields. - */ - public void readObject (ObjectInputStream in) - throws IOException, ClassNotFoundException - { - in.defaultReadObject(); - _username = in.readUTF(); - } - // documentation inherited public int hashCode () { diff --git a/src/java/com/threerings/presents/net/DownstreamMessage.java b/src/java/com/threerings/presents/net/DownstreamMessage.java index 7aa680bc6..b7501be2a 100644 --- a/src/java/com/threerings/presents/net/DownstreamMessage.java +++ b/src/java/com/threerings/presents/net/DownstreamMessage.java @@ -1,5 +1,5 @@ // -// $Id: DownstreamMessage.java,v 1.9 2002/07/23 05:52:48 mdb Exp $ +// $Id: DownstreamMessage.java,v 1.10 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -23,24 +23,6 @@ public abstract class DownstreamMessage extends SimpleStreamableObject */ public short messageId = -1; - /** - * Writes our custom streamable fields. - */ - public void writeObject (ObjectOutputStream out) - throws IOException - { - out.defaultWriteObject(); - } - - /** - * Reads our custom streamable fields. - */ - public void readObject (ObjectInputStream in) - throws IOException, ClassNotFoundException - { - in.defaultReadObject(); - } - /** * Generates a string representation of this instance. */ diff --git a/src/java/com/threerings/presents/net/EventNotification.java b/src/java/com/threerings/presents/net/EventNotification.java index 6708d0fef..0d2709527 100644 --- a/src/java/com/threerings/presents/net/EventNotification.java +++ b/src/java/com/threerings/presents/net/EventNotification.java @@ -1,5 +1,5 @@ // -// $Id: EventNotification.java,v 1.11 2002/07/23 05:52:48 mdb Exp $ +// $Id: EventNotification.java,v 1.12 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -33,26 +33,6 @@ public class EventNotification extends DownstreamMessage return _event; } - /** - * Writes our custom streamable fields. - */ - public void writeObject (ObjectOutputStream out) - throws IOException - { - super.writeObject(out); - out.writeObject(_event); - } - - /** - * Reads our custom streamable fields. - */ - public void readObject (ObjectInputStream in) - throws IOException, ClassNotFoundException - { - super.readObject(in); - _event = (DEvent)in.readObject(); - } - public String toString () { return "[type=EVT, evt=" + _event + "]"; diff --git a/src/java/com/threerings/presents/net/FailureResponse.java b/src/java/com/threerings/presents/net/FailureResponse.java index fca87fd66..cf9b693de 100644 --- a/src/java/com/threerings/presents/net/FailureResponse.java +++ b/src/java/com/threerings/presents/net/FailureResponse.java @@ -1,5 +1,5 @@ // -// $Id: FailureResponse.java,v 1.8 2002/07/23 05:52:48 mdb Exp $ +// $Id: FailureResponse.java,v 1.9 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -32,26 +32,6 @@ public class FailureResponse extends DownstreamMessage return _oid; } - /** - * Writes our custom streamable fields. - */ - public void writeObject (ObjectOutputStream out) - throws IOException - { - super.writeObject(out); - out.writeInt(_oid); - } - - /** - * Reads our custom streamable fields. - */ - public void readObject (ObjectInputStream in) - throws IOException, ClassNotFoundException - { - super.readObject(in); - _oid = in.readInt(); - } - public String toString () { return "[type=FAIL, msgid=" + messageId + ", oid=" + _oid + "]"; diff --git a/src/java/com/threerings/presents/net/ForwardEventRequest.java b/src/java/com/threerings/presents/net/ForwardEventRequest.java index 1dc13250e..9553039de 100644 --- a/src/java/com/threerings/presents/net/ForwardEventRequest.java +++ b/src/java/com/threerings/presents/net/ForwardEventRequest.java @@ -1,5 +1,5 @@ // -// $Id: ForwardEventRequest.java,v 1.10 2002/07/23 05:52:48 mdb Exp $ +// $Id: ForwardEventRequest.java,v 1.11 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -36,26 +36,6 @@ public class ForwardEventRequest extends UpstreamMessage return _event; } - /** - * Writes our custom streamable fields. - */ - public void writeObject (ObjectOutputStream out) - throws IOException - { - super.writeObject(out); - out.writeObject(_event); - } - - /** - * Reads our custom streamable fields. - */ - public void readObject (ObjectInputStream in) - throws IOException, ClassNotFoundException - { - super.readObject(in); - _event = (DEvent)in.readObject(); - } - public String toString () { return "[type=FWD, evt=" + _event + "]"; diff --git a/src/java/com/threerings/presents/net/ObjectResponse.java b/src/java/com/threerings/presents/net/ObjectResponse.java index d05c7affe..b65e5a946 100644 --- a/src/java/com/threerings/presents/net/ObjectResponse.java +++ b/src/java/com/threerings/presents/net/ObjectResponse.java @@ -1,5 +1,5 @@ // -// $Id: ObjectResponse.java,v 1.12 2002/07/23 05:52:48 mdb Exp $ +// $Id: ObjectResponse.java,v 1.13 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -33,26 +33,6 @@ public class ObjectResponse extends DownstreamMessage return _dobj; } - /** - * Writes our custom streamable fields. - */ - public void writeObject (ObjectOutputStream out) - throws IOException - { - super.writeObject(out); - out.writeObject(_dobj); - } - - /** - * Reads our custom streamable fields. - */ - public void readObject (ObjectInputStream in) - throws IOException, ClassNotFoundException - { - super.readObject(in); - _dobj = (DObject)in.readObject(); - } - public String toString () { return "[type=ORSP, msgid=" + messageId + ", obj=" + _dobj + "]"; diff --git a/src/java/com/threerings/presents/net/PingRequest.java b/src/java/com/threerings/presents/net/PingRequest.java index d478daddd..0a85c88ec 100644 --- a/src/java/com/threerings/presents/net/PingRequest.java +++ b/src/java/com/threerings/presents/net/PingRequest.java @@ -1,5 +1,5 @@ // -// $Id: PingRequest.java,v 1.8 2002/10/29 23:51:26 mdb Exp $ +// $Id: PingRequest.java,v 1.9 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -47,11 +47,11 @@ public class PingRequest extends UpstreamMessage public void writeObject (ObjectOutputStream out) throws IOException { - super.writeObject(out); - // grab a timestamp noting when we were encoded into a raw buffer // for delivery over the network _packStamp = System.currentTimeMillis(); + + out.defaultWriteObject(); } /** @@ -60,11 +60,11 @@ public class PingRequest extends UpstreamMessage public void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException { - super.readObject(in); - // grab a timestamp noting when we were decoded from a raw buffer // after being received over the network _unpackStamp = System.currentTimeMillis(); + + in.defaultReadObject(); } public String toString () @@ -73,10 +73,10 @@ public class PingRequest extends UpstreamMessage } /** A time stamp obtained when we serialize this object. */ - protected long _packStamp; + protected transient long _packStamp; /** A time stamp obtained when we unserialize this object (the intent * is to get a timestamp as close as possible to when the packet was * received on the network). */ - protected long _unpackStamp; + protected transient long _unpackStamp; } diff --git a/src/java/com/threerings/presents/net/PongResponse.java b/src/java/com/threerings/presents/net/PongResponse.java index d6915b6d8..b7586ef79 100644 --- a/src/java/com/threerings/presents/net/PongResponse.java +++ b/src/java/com/threerings/presents/net/PongResponse.java @@ -1,5 +1,5 @@ // -// $Id: PongResponse.java,v 1.8 2002/07/23 05:52:49 mdb Exp $ +// $Id: PongResponse.java,v 1.9 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -65,11 +65,8 @@ public class PongResponse extends DownstreamMessage public void writeObject (ObjectOutputStream out) throws IOException { - super.writeObject(out); - // make a note of the time at which we were packed _packStamp = System.currentTimeMillis(); - out.writeLong(_packStamp); // the time spent between unpacking the ping and packing the pong // is the processing delay @@ -80,7 +77,8 @@ public class PongResponse extends DownstreamMessage } else { _processDelay = (int)(_packStamp - _pingStamp); } - out.writeInt(_processDelay); + + out.defaultWriteObject(); } /** @@ -89,15 +87,11 @@ public class PongResponse extends DownstreamMessage public void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException { - super.readObject(in); - // grab a timestamp noting when we were decoded from a raw buffer // after being received over the network _unpackStamp = System.currentTimeMillis(); - // read in our time stamps - _packStamp = in.readLong(); - _processDelay = in.readInt(); + in.defaultReadObject(); } public String toString () @@ -108,7 +102,7 @@ public class PongResponse extends DownstreamMessage /** The ping unpack stamp provided at construct time to this pong * response; only valid on the sending process, not the receiving * process. */ - protected long _pingStamp; + protected transient long _pingStamp; /** The timestamp obtained immediately before this packet was sent out * over the network. */ @@ -122,5 +116,5 @@ public class PongResponse extends DownstreamMessage /** A time stamp obtained when we unserialize this object (the intent * is to get a timestamp as close as possible to when the packet was * received on the network). */ - protected long _unpackStamp; + protected transient long _unpackStamp; } diff --git a/src/java/com/threerings/presents/net/SubscribeRequest.java b/src/java/com/threerings/presents/net/SubscribeRequest.java index ef581f128..2451c819b 100644 --- a/src/java/com/threerings/presents/net/SubscribeRequest.java +++ b/src/java/com/threerings/presents/net/SubscribeRequest.java @@ -1,5 +1,5 @@ // -// $Id: SubscribeRequest.java,v 1.6 2002/07/23 05:52:49 mdb Exp $ +// $Id: SubscribeRequest.java,v 1.7 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -35,26 +35,6 @@ public class SubscribeRequest extends UpstreamMessage return _oid; } - /** - * Writes our custom streamable fields. - */ - public void writeObject (ObjectOutputStream out) - throws IOException - { - super.writeObject(out); - out.writeInt(_oid); - } - - /** - * Reads our custom streamable fields. - */ - public void readObject (ObjectInputStream in) - throws IOException, ClassNotFoundException - { - super.readObject(in); - _oid = in.readInt(); - } - public String toString () { return "[type=SUB, msgid=" + messageId + ", oid=" + _oid + "]"; diff --git a/src/java/com/threerings/presents/net/UnsubscribeRequest.java b/src/java/com/threerings/presents/net/UnsubscribeRequest.java index 5fe3fd70a..c1c17b775 100644 --- a/src/java/com/threerings/presents/net/UnsubscribeRequest.java +++ b/src/java/com/threerings/presents/net/UnsubscribeRequest.java @@ -1,5 +1,5 @@ // -// $Id: UnsubscribeRequest.java,v 1.7 2002/07/23 05:52:49 mdb Exp $ +// $Id: UnsubscribeRequest.java,v 1.8 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -35,26 +35,6 @@ public class UnsubscribeRequest extends UpstreamMessage return _oid; } - /** - * Writes our custom streamable fields. - */ - public void writeObject (ObjectOutputStream out) - throws IOException - { - super.writeObject(out); - out.writeInt(_oid); - } - - /** - * Reads our custom streamable fields. - */ - public void readObject (ObjectInputStream in) - throws IOException, ClassNotFoundException - { - super.readObject(in); - _oid = in.readInt(); - } - public String toString () { return "[type=UNSUB, msgid=" + messageId + ", oid=" + _oid + "]"; diff --git a/src/java/com/threerings/presents/net/UpstreamMessage.java b/src/java/com/threerings/presents/net/UpstreamMessage.java index e98420294..0a8524754 100644 --- a/src/java/com/threerings/presents/net/UpstreamMessage.java +++ b/src/java/com/threerings/presents/net/UpstreamMessage.java @@ -1,5 +1,5 @@ // -// $Id: UpstreamMessage.java,v 1.9 2002/07/23 05:52:49 mdb Exp $ +// $Id: UpstreamMessage.java,v 1.10 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -37,24 +37,6 @@ public abstract class UpstreamMessage extends SimpleStreamableObject this.messageId = nextMessageId(); } - /** - * Writes our custom streamable fields. - */ - public void writeObject (ObjectOutputStream out) - throws IOException - { - out.defaultWriteObject(); - } - - /** - * Reads our custom streamable fields. - */ - public void readObject (ObjectInputStream in) - throws IOException, ClassNotFoundException - { - in.defaultReadObject(); - } - public String toString () { return "[msgid=" + messageId + "]"; diff --git a/src/java/com/threerings/presents/net/UsernamePasswordCreds.java b/src/java/com/threerings/presents/net/UsernamePasswordCreds.java index 2bafd57c4..0c70fd031 100644 --- a/src/java/com/threerings/presents/net/UsernamePasswordCreds.java +++ b/src/java/com/threerings/presents/net/UsernamePasswordCreds.java @@ -1,5 +1,5 @@ // -// $Id: UsernamePasswordCreds.java,v 1.9 2002/09/18 22:06:54 mdb Exp $ +// $Id: UsernamePasswordCreds.java,v 1.10 2002/12/20 23:28:24 mdb Exp $ package com.threerings.presents.net; @@ -32,26 +32,6 @@ public class UsernamePasswordCreds extends Credentials return _password; } - /** - * Writes our custom streamable fields. - */ - public void writeObject (ObjectOutputStream out) - throws IOException - { - super.writeObject(out); - out.writeUTF(_password); - } - - /** - * Reads our custom streamable fields. - */ - public void readObject (ObjectInputStream in) - throws IOException, ClassNotFoundException - { - super.readObject(in); - _password = in.readUTF(); - } - // documentation inherited public int hashCode () {