Styley stylopolis.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5252 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-07-22 14:01:51 +00:00
parent 706b85a0e4
commit 5c4ab96880
26 changed files with 139 additions and 77 deletions
@@ -23,6 +23,9 @@ package com.threerings.presents.net;
import com.threerings.presents.dobj.DEvent;
/**
* Contains an event forwarded from the server.
*/
public class EventNotification extends DownstreamMessage
{
/**
@@ -21,6 +21,9 @@
package com.threerings.presents.net;
/**
* Communicates failure to subscribe to an object.
*/
public class FailureResponse extends DownstreamMessage
{
/**
@@ -23,6 +23,9 @@ package com.threerings.presents.net;
import com.threerings.presents.dobj.DEvent;
/**
* Forwards an event to the server for dispatch.
*/
public class ForwardEventRequest extends UpstreamMessage
{
/**
@@ -21,6 +21,9 @@
package com.threerings.presents.net;
/**
* Requests to end our session with the server.
*/
public class LogoffRequest extends UpstreamMessage
{
/**
@@ -23,6 +23,11 @@ package com.threerings.presents.net;
import com.threerings.presents.dobj.DObject;
/**
* Contains a distributed object to which the client has subscribed.
*
* @param <T> the type of object delivered by the response.
*/
public class ObjectResponse<T extends DObject>
extends DownstreamMessage
{
@@ -26,11 +26,13 @@ import java.io.IOException;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
/**
* Let's the server know we're still alive.
*/
public class PingRequest extends UpstreamMessage
{
/** The number of milliseconds of idle upstream that are allowed to
* elapse before the client sends a ping message to the server to let
* it know that we're still alive. */
/** The number of milliseconds of idle upstream that are allowed to elapse before the client
* sends a ping message to the server to let it know that we're still alive. */
public static final long PING_INTERVAL = 60 * 1000L;
/**
@@ -50,8 +52,8 @@ public class PingRequest extends UpstreamMessage
}
/**
* Returns a timestamp that was obtained when this packet was encoded
* by the low-level networking code.
* Returns a timestamp that was obtained when this packet was encoded by the low-level
* networking code.
*/
public long getPackStamp ()
{
@@ -59,8 +61,8 @@ public class PingRequest extends UpstreamMessage
}
/**
* Returns a timestamp that was obtained when this packet was decoded
* by the low-level networking code.
* Returns a timestamp that was obtained when this packet was decoded by the low-level
* networking code.
*/
public long getUnpackStamp ()
{
@@ -73,8 +75,8 @@ public class PingRequest extends UpstreamMessage
public void writeObject (ObjectOutputStream out)
throws IOException
{
// grab a timestamp noting when we were encoded into a raw buffer
// for delivery over the network
// grab a timestamp noting when we were encoded into a raw buffer for delivery over the
// network
_packStamp = System.currentTimeMillis();
out.defaultWriteObject();
@@ -86,8 +88,8 @@ public class PingRequest extends UpstreamMessage
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
// grab a timestamp noting when we were decoded from a raw buffer
// after being received over the network
// grab a timestamp noting when we were decoded from a raw buffer after being received over
// the network
_unpackStamp = System.currentTimeMillis();
in.defaultReadObject();
@@ -114,9 +116,8 @@ public class PingRequest extends UpstreamMessage
/** A time stamp obtained when we serialize this object. */
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). */
/** 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 transient long _unpackStamp;
/** The transport parameters. */
@@ -28,6 +28,10 @@ import com.threerings.io.ObjectOutputStream;
import static com.threerings.presents.Log.log;
/**
* Let's the client know the server heard its ping (and that the server and connection are still
* alive).
*/
public class PongResponse extends DownstreamMessage
{
/**
@@ -39,20 +43,19 @@ public class PongResponse extends DownstreamMessage
}
/**
* Constructs a pong response which will use the supplied ping time to
* establish the end-to-end processing delay introduced by the server.
* Constructs a pong response which will use the supplied ping time to establish the end-to-end
* processing delay introduced by the server.
*/
public PongResponse (long pingStamp, Transport transport)
{
// save this for when we are serialized in preparation for
// delivery over the network
// save this for when we are serialized in preparation for delivery over the network
_pingStamp = pingStamp;
_transport = transport;
}
/**
* Returns the time at which this packet was packed for delivery in
* the time frame of the server that sent the packet.
* Returns the time at which this packet was packed for delivery in the time frame of the
* server that sent the packet.
*/
public long getPackStamp ()
{
@@ -60,9 +63,9 @@ public class PongResponse extends DownstreamMessage
}
/**
* Returns the number of milliseconds that elapsed between the time
* that the ping which instigated this pong was read from the network
* and the time that this pong was written to the network.
* Returns the number of milliseconds that elapsed between the time that the ping which
* instigated this pong was read from the network and the time that this pong was written to
* the network.
*/
public int getProcessDelay ()
{
@@ -70,8 +73,8 @@ public class PongResponse extends DownstreamMessage
}
/**
* Returns a timestamp that was obtained when this packet was decoded
* by the low-level networking code.
* Returns a timestamp that was obtained when this packet was decoded by the low-level
* networking code.
*/
public long getUnpackStamp ()
{
@@ -87,8 +90,7 @@ public class PongResponse extends DownstreamMessage
// make a note of the time at which we were packed
_packStamp = System.currentTimeMillis();
// the time spent between unpacking the ping and packing the pong
// is the processing delay
// the time spent between unpacking the ping and packing the pong is the processing delay
if (_pingStamp == 0L) {
log.warning("Pong response written that was not constructed " +
"with a valid ping stamp [rsp=" + this + "].");
@@ -106,8 +108,8 @@ public class PongResponse extends DownstreamMessage
public void readObject (ObjectInputStream in)
throws IOException, ClassNotFoundException
{
// grab a timestamp noting when we were decoded from a raw buffer
// after being received over the network
// grab a timestamp noting when we were decoded from a raw buffer after being received over
// the network
_unpackStamp = System.currentTimeMillis();
in.defaultReadObject();
@@ -131,23 +133,19 @@ public class PongResponse extends DownstreamMessage
return "[type=PONG, msgid=" + messageId + ", transport=" + _transport + "]";
}
/** The ping unpack stamp provided at construct time to this pong
* response; only valid on the sending process, not the receiving
* process. */
/** The ping unpack stamp provided at construct time to this pong response; only valid on the
* sending process, not the receiving process. */
protected transient long _pingStamp;
/** The timestamp obtained immediately before this packet was sent out
* over the network. */
/** The timestamp obtained immediately before this packet was sent out over the network. */
protected long _packStamp;
/** The delay in milliseconds between the time that the ping request
* was read from the network and the time the pong response was
* written to the network. */
/** The delay in milliseconds between the time that the ping request was read from the network
* and the time the pong response was written to the network. */
protected int _processDelay;
/** 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). */
/** 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 transient long _unpackStamp;
/** The transport parameters. */
@@ -21,6 +21,9 @@
package com.threerings.presents.net;
/**
* Requests to subscribe to a particular distributed object.
*/
public class SubscribeRequest extends UpstreamMessage
{
/**
@@ -25,8 +25,8 @@ import com.samskivert.util.HashIntMap;
/**
* Message transport parameters. These include the type of transport and the channel (used to
* define independent streams for ordered transport), and may eventually include message
* priority, etc.
* define independent streams for ordered transport), and may eventually include message priority,
* etc.
*/
public class Transport
{
@@ -109,8 +109,8 @@ public class Transport
}
protected boolean _reliable, _ordered;
}
}
/** The unreliable/unordered mode of transport. */
public static final Transport UNRELIABLE_UNORDERED = getInstance(Type.UNRELIABLE_UNORDERED);
@@ -21,6 +21,9 @@
package com.threerings.presents.net;
/**
* Requests to end a subscription to a particular distributed object.
*/
public class UnsubscribeRequest extends UpstreamMessage
{
/**
@@ -23,6 +23,9 @@ package com.threerings.presents.net;
import com.threerings.util.Name;
/**
* Extends the basic credentials with a password.
*/
public class UsernamePasswordCreds extends Credentials
{
/**