Brought code into line with the new streaming world order.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1606 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,19 +1,15 @@
|
||||
//
|
||||
// $Id: AuthRequest.java,v 1.7 2001/10/11 04:07:53 mdb Exp $
|
||||
// $Id: AuthRequest.java,v 1.8 2002/07/23 05:52:48 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.presents.io.TypedObjectFactory;
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
public class AuthRequest extends UpstreamMessage
|
||||
{
|
||||
/** The code for an auth request. */
|
||||
public static final short TYPE = TYPE_BASE + 0;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
@@ -30,28 +26,29 @@ public class AuthRequest extends UpstreamMessage
|
||||
_creds = creds;
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public Credentials getCredentials ()
|
||||
{
|
||||
return _creds;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out)
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
TypedObjectFactory.writeTo(out, _creds);
|
||||
super.writeObject(out);
|
||||
out.writeObject(_creds);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
super.readFrom(in);
|
||||
_creds = (Credentials)TypedObjectFactory.readFrom(in);
|
||||
super.readObject(in);
|
||||
_creds = (Credentials)in.readObject();
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
//
|
||||
// $Id: AuthResponse.java,v 1.11 2002/03/05 05:39:52 mdb Exp $
|
||||
// $Id: AuthResponse.java,v 1.12 2002/07/23 05:52:48 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.presents.dobj.io.DObjectFactory;
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
/**
|
||||
* The auth response communicates authentication success or failure as
|
||||
@@ -18,9 +17,6 @@ import com.threerings.presents.dobj.io.DObjectFactory;
|
||||
*/
|
||||
public class AuthResponse extends DownstreamMessage
|
||||
{
|
||||
/** The code for an auth response. */
|
||||
public static final short TYPE = TYPE_BASE + 0;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
@@ -42,23 +38,24 @@ public class AuthResponse extends DownstreamMessage
|
||||
return _data;
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out)
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
DObjectFactory.writeTo(out, _data);
|
||||
super.writeObject(out);
|
||||
out.writeObject(_data);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
super.readFrom(in);
|
||||
_data = (AuthResponseData)DObjectFactory.readFrom(in);
|
||||
super.readObject(in);
|
||||
_data = (AuthResponseData)in.readObject();
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
//
|
||||
// $Id: BootstrapNotification.java,v 1.3 2001/10/11 04:07:53 mdb Exp $
|
||||
// $Id: BootstrapNotification.java,v 1.4 2002/07/23 05:52:48 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.presents.dobj.io.DObjectFactory;
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
/**
|
||||
* A bootstrap notification is delivered to the client once the server has
|
||||
@@ -19,9 +18,6 @@ import com.threerings.presents.dobj.io.DObjectFactory;
|
||||
*/
|
||||
public class BootstrapNotification extends DownstreamMessage
|
||||
{
|
||||
/** The code for a bootstrap notification. */
|
||||
public static final short TYPE = TYPE_BASE + 1;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
@@ -38,28 +34,29 @@ public class BootstrapNotification extends DownstreamMessage
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BootstrapData getData ()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out)
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
DObjectFactory.writeTo(out, _data);
|
||||
super.writeObject(out);
|
||||
out.writeObject(_data);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
super.readFrom(in);
|
||||
_data = (BootstrapData)DObjectFactory.readFrom(in);
|
||||
super.readObject(in);
|
||||
_data = (BootstrapData)in.readObject();
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
//
|
||||
// $Id: Credentials.java,v 1.7 2001/10/11 04:07:53 mdb Exp $
|
||||
// $Id: Credentials.java,v 1.8 2002/07/23 05:52:48 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.presents.io.TypedObject;
|
||||
import com.threerings.presents.io.TypedObjectFactory;
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.Streamable;
|
||||
|
||||
/**
|
||||
* Credentials are supplied by the client implementation and sent along to
|
||||
@@ -24,14 +23,8 @@ import com.threerings.presents.io.TypedObjectFactory;
|
||||
* that they can be instantiated prior to reconstruction from a data input
|
||||
* stream.
|
||||
*/
|
||||
public abstract class Credentials implements TypedObject
|
||||
public abstract class Credentials implements Streamable
|
||||
{
|
||||
/**
|
||||
* All credential derived classes should base their typed object code
|
||||
* on this base value.
|
||||
*/
|
||||
public static final short TYPE_BASE = 300;
|
||||
|
||||
/**
|
||||
* Constructs a credentials instance with the specified username.
|
||||
*/
|
||||
@@ -54,24 +47,22 @@ public abstract class Credentials implements TypedObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived classes should override this function to write their fields
|
||||
* out to the supplied data output stream. They <em>must</em> be sure
|
||||
* to first call <code>super.writeTo()</code>.
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeTo (DataOutputStream out)
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
out.defaultWriteObject();
|
||||
out.writeUTF(_username);
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived classes should override this function to read their fields
|
||||
* from the supplied data input stream. They <em>must</em> be sure to
|
||||
* first call <code>super.readFrom()</code>.
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
in.defaultReadObject();
|
||||
_username = in.readUTF();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,71 +1,49 @@
|
||||
//
|
||||
// $Id: DownstreamMessage.java,v 1.8 2001/10/11 04:07:53 mdb Exp $
|
||||
// $Id: DownstreamMessage.java,v 1.9 2002/07/23 05:52:48 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.presents.io.TypedObject;
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.SimpleStreamableObject;
|
||||
|
||||
/**
|
||||
* The <code>DownstreamMessage</code> class encapsulates a message in the
|
||||
* Distributed Object Protocol that flows from the server to the
|
||||
* client. Downstream messages include object subscription, event
|
||||
* forwarding and session management.
|
||||
* This class encapsulates a message in the distributed object protocol
|
||||
* that flows from the server to the client. Downstream messages include
|
||||
* object subscription, event forwarding and session management.
|
||||
*/
|
||||
public abstract class DownstreamMessage implements TypedObject
|
||||
public abstract class DownstreamMessage extends SimpleStreamableObject
|
||||
{
|
||||
/**
|
||||
* All downstream message derived classes should base their typed
|
||||
* object code on this base value.
|
||||
*/
|
||||
public static final short TYPE_BASE = 200;
|
||||
|
||||
/**
|
||||
* The message id of the upstream message with which this downstream
|
||||
* message is associated (or -1 if it is not associated with any
|
||||
* upstream message). Because not every downstream message class cares
|
||||
* to provide an upstream message id, this field is not serialized
|
||||
* when the base downstream message class is serialized. Thus derived
|
||||
* classes that care about message id should take care to initialize,
|
||||
* serialize and unserialize the value theirselves.
|
||||
* upstream message).
|
||||
*/
|
||||
public short messageId = -1;
|
||||
|
||||
/**
|
||||
* Each downstream message derived class must provide a zero argument
|
||||
* constructor so that the <code>TypedObjectFactory</code> can create
|
||||
* a new instance of said class prior to unserializing it.
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public DownstreamMessage ()
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
// nothing to do...
|
||||
out.defaultWriteObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived classes should override this function to write their fields
|
||||
* out to the supplied data output stream. They <em>must</em> be sure
|
||||
* to first call <code>super.writeTo()</code>.
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void writeTo (DataOutputStream out)
|
||||
throws IOException
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
// we don't do anything here, but we may want to some day
|
||||
in.defaultReadObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived classes should override this function to read their fields
|
||||
* from the supplied data input stream. They <em>must</em> be sure to
|
||||
* first call <code>super.readFrom()</code>.
|
||||
* Generates a string representation of this instance.
|
||||
*/
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
{
|
||||
// we don't do anything here, but we may want to some day
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
{
|
||||
return "[msgid=" + messageId + "]";
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
//
|
||||
// $Id: EventNotification.java,v 1.10 2001/10/11 04:07:53 mdb Exp $
|
||||
// $Id: EventNotification.java,v 1.11 2002/07/23 05:52:48 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.presents.dobj.TypedEvent;
|
||||
import com.threerings.presents.io.TypedObjectFactory;
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.presents.dobj.DEvent;
|
||||
|
||||
public class EventNotification extends DownstreamMessage
|
||||
{
|
||||
/** The code for an event notification. */
|
||||
public static final short TYPE = TYPE_BASE + 2;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
@@ -26,42 +23,41 @@ public class EventNotification extends DownstreamMessage
|
||||
/**
|
||||
* Constructs an event notification for the supplied event.
|
||||
*/
|
||||
public EventNotification (TypedEvent event)
|
||||
public EventNotification (DEvent event)
|
||||
{
|
||||
_event = event;
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public TypedEvent getEvent ()
|
||||
public DEvent getEvent ()
|
||||
{
|
||||
return _event;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out)
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
// write the event out to the stream
|
||||
TypedObjectFactory.writeTo(out, _event);
|
||||
super.writeObject(out);
|
||||
out.writeObject(_event);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
super.readFrom(in);
|
||||
// read the event in from the stream
|
||||
_event = (TypedEvent)TypedObjectFactory.readFrom(in);
|
||||
super.readObject(in);
|
||||
_event = (DEvent)in.readObject();
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
{
|
||||
return "[type=EVT, msgid=" + messageId + ", evt=" + _event + "]";
|
||||
return "[type=EVT, evt=" + _event + "]";
|
||||
}
|
||||
|
||||
/** The event which we are forwarding. */
|
||||
protected TypedEvent _event;
|
||||
protected DEvent _event;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
//
|
||||
// $Id: FailureResponse.java,v 1.7 2001/10/11 04:07:53 mdb Exp $
|
||||
// $Id: FailureResponse.java,v 1.8 2002/07/23 05:52:48 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
public class FailureResponse extends DownstreamMessage
|
||||
{
|
||||
/** The code for a failure notification. */
|
||||
public static final short TYPE = TYPE_BASE + 4;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
@@ -29,27 +27,28 @@ public class FailureResponse extends DownstreamMessage
|
||||
_oid = oid;
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public int getOid ()
|
||||
{
|
||||
return _oid;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out)
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
super.writeObject(out);
|
||||
out.writeInt(_oid);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
super.readFrom(in);
|
||||
super.readObject(in);
|
||||
_oid = in.readInt();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
//
|
||||
// $Id: ForwardEventRequest.java,v 1.9 2001/10/11 04:07:53 mdb Exp $
|
||||
// $Id: ForwardEventRequest.java,v 1.10 2002/07/23 05:52:48 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.presents.dobj.TypedEvent;
|
||||
import com.threerings.presents.io.TypedObjectFactory;
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.presents.dobj.DEvent;
|
||||
|
||||
public class ForwardEventRequest extends UpstreamMessage
|
||||
{
|
||||
/** The code for a forward event request. */
|
||||
public static final short TYPE = TYPE_BASE + 4;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
@@ -26,45 +23,44 @@ public class ForwardEventRequest extends UpstreamMessage
|
||||
/**
|
||||
* Constructs a forward event request for the supplied event.
|
||||
*/
|
||||
public ForwardEventRequest (TypedEvent event)
|
||||
public ForwardEventRequest (DEvent event)
|
||||
{
|
||||
_event = event;
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the event that we wish to have forwarded.
|
||||
*/
|
||||
public TypedEvent getEvent ()
|
||||
public DEvent getEvent ()
|
||||
{
|
||||
return _event;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out)
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
// write the event out to the stream
|
||||
TypedObjectFactory.writeTo(out, _event);
|
||||
super.writeObject(out);
|
||||
out.writeObject(_event);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
super.readFrom(in);
|
||||
// read the event in from the stream
|
||||
_event = (TypedEvent)TypedObjectFactory.readFrom(in);
|
||||
super.readObject(in);
|
||||
_event = (DEvent)in.readObject();
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
{
|
||||
return "[type=FWD, msgid=" + messageId + ", evt=" + _event + "]";
|
||||
return "[type=FWD, evt=" + _event + "]";
|
||||
}
|
||||
|
||||
/** The event which we are forwarding. */
|
||||
protected TypedEvent _event;
|
||||
protected DEvent _event;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
//
|
||||
// $Id: LogoffRequest.java,v 1.5 2001/10/11 04:07:53 mdb Exp $
|
||||
// $Id: LogoffRequest.java,v 1.6 2002/07/23 05:52:48 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
public class LogoffRequest extends UpstreamMessage
|
||||
{
|
||||
/** The code for a logoff request. */
|
||||
public static final short TYPE = TYPE_BASE + 6;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
@@ -16,11 +13,6 @@ public class LogoffRequest extends UpstreamMessage
|
||||
super();
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
{
|
||||
return "[type=LOGOFF, msgid=" + messageId + "]";
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
//
|
||||
// $Id: ObjectResponse.java,v 1.11 2001/10/11 04:07:53 mdb Exp $
|
||||
// $Id: ObjectResponse.java,v 1.12 2002/07/23 05:52:48 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.presents.dobj.DObject;
|
||||
import com.threerings.presents.dobj.io.DObjectFactory;
|
||||
|
||||
public class ObjectResponse extends DownstreamMessage
|
||||
{
|
||||
/** The code for an object repsonse. */
|
||||
public static final short TYPE = TYPE_BASE + 3;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
@@ -31,28 +28,29 @@ public class ObjectResponse extends DownstreamMessage
|
||||
_dobj = dobj;
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public DObject getObject ()
|
||||
{
|
||||
return _dobj;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out)
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
DObjectFactory.writeTo(out, _dobj);
|
||||
super.writeObject(out);
|
||||
out.writeObject(_dobj);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
super.readFrom(in);
|
||||
_dobj = (DObject)DObjectFactory.readFrom(in);
|
||||
super.readObject(in);
|
||||
_dobj = (DObject)in.readObject();
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
//
|
||||
// $Id: PingRequest.java,v 1.6 2002/05/28 21:56:38 mdb Exp $
|
||||
// $Id: PingRequest.java,v 1.7 2002/07/23 05:52:48 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
public class PingRequest extends UpstreamMessage
|
||||
{
|
||||
/** The code for a ping request. */
|
||||
public static final short TYPE = TYPE_BASE + 5;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
@@ -38,33 +36,32 @@ public class PingRequest extends UpstreamMessage
|
||||
return _unpackStamp;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void writeTo (DataOutputStream out)
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
super.writeObject(out);
|
||||
|
||||
// grab a timestamp noting when we were encoded into a raw buffer
|
||||
// for delivery over the network
|
||||
_packStamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
super.readFrom(in);
|
||||
super.readObject(in);
|
||||
|
||||
// grab a timestamp noting when we were decoded from a raw buffer
|
||||
// after being received over the network
|
||||
_unpackStamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
{
|
||||
return "[type=PING, msgid=" + messageId + "]";
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
//
|
||||
// $Id: PongResponse.java,v 1.7 2002/05/28 21:56:38 mdb Exp $
|
||||
// $Id: PongResponse.java,v 1.8 2002/07/23 05:52:49 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
import com.threerings.presents.Log;
|
||||
|
||||
public class PongResponse extends DownstreamMessage
|
||||
{
|
||||
/** The code for a pong response. */
|
||||
public static final short TYPE = TYPE_BASE + 5;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
@@ -61,11 +59,13 @@ public class PongResponse extends DownstreamMessage
|
||||
return _unpackStamp;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void writeTo (DataOutputStream out)
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
super.writeObject(out);
|
||||
|
||||
// make a note of the time at which we were packed
|
||||
_packStamp = System.currentTimeMillis();
|
||||
@@ -83,11 +83,13 @@ public class PongResponse extends DownstreamMessage
|
||||
out.writeInt(_processDelay);
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
super.readFrom(in);
|
||||
super.readObject(in);
|
||||
|
||||
// grab a timestamp noting when we were decoded from a raw buffer
|
||||
// after being received over the network
|
||||
@@ -98,11 +100,6 @@ public class PongResponse extends DownstreamMessage
|
||||
_processDelay = in.readInt();
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
{
|
||||
return "[type=PONG, msgid=" + messageId + "]";
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
//
|
||||
// $Id: SubscribeRequest.java,v 1.5 2001/10/11 04:07:53 mdb Exp $
|
||||
// $Id: SubscribeRequest.java,v 1.6 2002/07/23 05:52:49 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
public class SubscribeRequest extends UpstreamMessage
|
||||
{
|
||||
/** The code for an object subscription request. */
|
||||
public static final short TYPE = TYPE_BASE + 1;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
@@ -29,11 +27,6 @@ public class SubscribeRequest extends UpstreamMessage
|
||||
_oid = oid;
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the oid of the object to which we desire subscription.
|
||||
*/
|
||||
@@ -42,17 +35,23 @@ public class SubscribeRequest extends UpstreamMessage
|
||||
return _oid;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out)
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
super.writeObject(out);
|
||||
out.writeInt(_oid);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
super.readFrom(in);
|
||||
super.readObject(in);
|
||||
_oid = in.readInt();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
//
|
||||
// $Id: UnsubscribeRequest.java,v 1.6 2001/10/11 04:07:53 mdb Exp $
|
||||
// $Id: UnsubscribeRequest.java,v 1.7 2002/07/23 05:52:49 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
public class UnsubscribeRequest extends UpstreamMessage
|
||||
{
|
||||
/** The code for an unsubscribe request. */
|
||||
public static final short TYPE = TYPE_BASE + 3;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
@@ -29,11 +27,6 @@ public class UnsubscribeRequest extends UpstreamMessage
|
||||
_oid = oid;
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the oid of the object from which we are unsubscribing.
|
||||
*/
|
||||
@@ -42,17 +35,23 @@ public class UnsubscribeRequest extends UpstreamMessage
|
||||
return _oid;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out)
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
super.writeObject(out);
|
||||
out.writeInt(_oid);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
super.readFrom(in);
|
||||
super.readObject(in);
|
||||
_oid = in.readInt();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,21 @@
|
||||
//
|
||||
// $Id: UpstreamMessage.java,v 1.8 2001/10/11 04:07:53 mdb Exp $
|
||||
// $Id: UpstreamMessage.java,v 1.9 2002/07/23 05:52:49 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
import com.threerings.presents.io.TypedObject;
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.SimpleStreamableObject;
|
||||
|
||||
/**
|
||||
* The <code>UpstreamMessage</code> class encapsulates a message in the
|
||||
* Distributed Object Protocol that flows from the client to the server.
|
||||
* Upstream messages include object subscription, event forwarding and
|
||||
* session management.
|
||||
* This class encapsulates a message in the distributed object protocol
|
||||
* that flows from the client to the server. Upstream messages include
|
||||
* object subscription, event forwarding and session management.
|
||||
*/
|
||||
public abstract class UpstreamMessage implements TypedObject
|
||||
public abstract class UpstreamMessage extends SimpleStreamableObject
|
||||
{
|
||||
/**
|
||||
* All upstream message derived classes should base their typed object
|
||||
* code on this base value.
|
||||
*/
|
||||
public static final short TYPE_BASE = 100;
|
||||
|
||||
/**
|
||||
* This is a unique (within the context of a reasonable period of
|
||||
* time) identifier assigned to each upstream message. The message ids
|
||||
@@ -33,8 +26,8 @@ public abstract class UpstreamMessage implements TypedObject
|
||||
|
||||
/**
|
||||
* Each upstream message derived class must provide a zero argument
|
||||
* constructor so that the <code>TypedObjectFactory</code> can create
|
||||
* a new instance of said class prior to unserializing it.
|
||||
* constructor so that it can be unserialized when read from the
|
||||
* network.
|
||||
*/
|
||||
public UpstreamMessage ()
|
||||
{
|
||||
@@ -45,25 +38,21 @@ public abstract class UpstreamMessage implements TypedObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived classes should override this function to write their fields
|
||||
* out to the supplied data output stream. They <em>must</em> be sure
|
||||
* to first call <code>super.writeTo()</code>.
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeTo (DataOutputStream out)
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
out.writeShort(messageId);
|
||||
out.defaultWriteObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived classes should override this function to read their fields
|
||||
* from the supplied data input stream. They <em>must</em> be sure to
|
||||
* first call <code>super.readFrom()</code>.
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
messageId = in.readShort();
|
||||
in.defaultReadObject();
|
||||
}
|
||||
|
||||
public String toString ()
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
//
|
||||
// $Id: UsernamePasswordCreds.java,v 1.6 2001/10/11 04:07:53 mdb Exp $
|
||||
// $Id: UsernamePasswordCreds.java,v 1.7 2002/07/23 05:52:49 mdb Exp $
|
||||
|
||||
package com.threerings.presents.net;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
|
||||
public class UsernamePasswordCreds extends Credentials
|
||||
{
|
||||
public static final short TYPE = TYPE_BASE + 0;
|
||||
|
||||
/**
|
||||
* Zero argument constructor used when unserializing an instance.
|
||||
*/
|
||||
@@ -28,27 +27,28 @@ public class UsernamePasswordCreds extends Credentials
|
||||
_password = password;
|
||||
}
|
||||
|
||||
public short getType ()
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public String getPassword ()
|
||||
{
|
||||
return _password;
|
||||
}
|
||||
|
||||
public void writeTo (DataOutputStream out)
|
||||
/**
|
||||
* Writes our custom streamable fields.
|
||||
*/
|
||||
public void writeObject (ObjectOutputStream out)
|
||||
throws IOException
|
||||
{
|
||||
super.writeTo(out);
|
||||
super.writeObject(out);
|
||||
out.writeUTF(_password);
|
||||
}
|
||||
|
||||
public void readFrom (DataInputStream in)
|
||||
throws IOException
|
||||
/**
|
||||
* Reads our custom streamable fields.
|
||||
*/
|
||||
public void readObject (ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
super.readFrom(in);
|
||||
super.readObject(in);
|
||||
_password = in.readUTF();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user