Progress on the presents client.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3848 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-02-13 22:07:50 +00:00
parent ad7e4f6be6
commit 8366c150f4
7 changed files with 220 additions and 2 deletions
@@ -0,0 +1,48 @@
package com.threerings.presents.net {
import com.threerings.io.Streamable;
public class UpstreamMessage
implements Streamable
{
/** This is a unique (within the context of a reasonable period
* of time) identifier assigned to each upstream message. The message ids
* are used to correlate a downstream response message to the
* appropriate upstream request message. */
public var messageId :int;
/**
* Construct an upstream message.
*/
public function UpstreamMessage ()
{
// automatically generate a valid message id
this.messageId = nextMessageId();
}
// documentation inherited from interface Streamable
public function writeObject (out :ObjectOutputStream) :void
{
out.writeShort(messageId);
}
// documentation inherited from interface Streamable
public function readObject (ins :ObjectInputStream) :void
{
messageId = ins.readShort();
}
/**
* Returns the next message id suitable for use by an upstream message./
*/
protected static function nextMessageId () :int
{
_nextMessageId = (_nextMessageId + 1) % JavaConstants.SHORT_MAX_VALUE;
return _nextMessageId;
}
/** This is used to generate monotonically increasing message ids on the
* client as new messages are generated. */
protected static var _nextMessageId :int;
}
}