Styley stylopolis.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5252 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -35,8 +35,25 @@ import com.samskivert.util.StringUtil;
|
|||||||
import com.samskivert.util.IntMap;
|
import com.samskivert.util.IntMap;
|
||||||
import com.samskivert.util.Interval;
|
import com.samskivert.util.Interval;
|
||||||
|
|
||||||
import com.threerings.presents.dobj.*;
|
import com.threerings.presents.dobj.CompoundEvent;
|
||||||
import com.threerings.presents.net.*;
|
import com.threerings.presents.dobj.DEvent;
|
||||||
|
import com.threerings.presents.dobj.DObject;
|
||||||
|
import com.threerings.presents.dobj.DObjectManager;
|
||||||
|
import com.threerings.presents.dobj.ObjectAccessException;
|
||||||
|
import com.threerings.presents.dobj.ObjectDestroyedEvent;
|
||||||
|
import com.threerings.presents.dobj.Subscriber;
|
||||||
|
|
||||||
|
import com.threerings.presents.net.BootstrapData;
|
||||||
|
import com.threerings.presents.net.BootstrapNotification;
|
||||||
|
import com.threerings.presents.net.DownstreamMessage;
|
||||||
|
import com.threerings.presents.net.EventNotification;
|
||||||
|
import com.threerings.presents.net.FailureResponse;
|
||||||
|
import com.threerings.presents.net.ForwardEventRequest;
|
||||||
|
import com.threerings.presents.net.ObjectResponse;
|
||||||
|
import com.threerings.presents.net.PongResponse;
|
||||||
|
import com.threerings.presents.net.SubscribeRequest;
|
||||||
|
import com.threerings.presents.net.UnsubscribeRequest;
|
||||||
|
import com.threerings.presents.net.UnsubscribeResponse;
|
||||||
|
|
||||||
import static com.threerings.presents.Log.log;
|
import static com.threerings.presents.Log.log;
|
||||||
|
|
||||||
|
|||||||
@@ -913,7 +913,7 @@ public class DObject
|
|||||||
protected transient boolean _deathWish = false;
|
protected transient boolean _deathWish = false;
|
||||||
|
|
||||||
/** Maintains a mapping of sorted field arrays for each distributed object class. */
|
/** Maintains a mapping of sorted field arrays for each distributed object class. */
|
||||||
protected static HashMap<Class,Field[]> _ftable = new HashMap<Class,Field[]>();
|
protected static HashMap<Class, Field[]> _ftable = new HashMap<Class, Field[]>();
|
||||||
|
|
||||||
/** Used to sort and search {@link #_fields}. */
|
/** Used to sort and search {@link #_fields}. */
|
||||||
protected static final Comparator<Field> FIELD_COMP = new Comparator<Field>() {
|
protected static final Comparator<Field> FIELD_COMP = new Comparator<Field>() {
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import java.util.ConcurrentModificationException;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import com.samskivert.util.ArrayUtil;
|
import com.samskivert.util.ArrayUtil;
|
||||||
import com.samskivert.util.StringUtil;
|
|
||||||
|
|
||||||
import com.threerings.io.ObjectInputStream;
|
import com.threerings.io.ObjectInputStream;
|
||||||
import com.threerings.io.ObjectOutputStream;
|
import com.threerings.io.ObjectOutputStream;
|
||||||
@@ -49,6 +48,8 @@ import static com.threerings.presents.Log.log;
|
|||||||
* case of entry removal, only the key for the entry to be removed will be transmitted with the
|
* case of entry removal, only the key for the entry to be removed will be transmitted with the
|
||||||
* removal event to save network bandwidth. Lastly, the object returned by {@link Entry#getKey}
|
* removal event to save network bandwidth. Lastly, the object returned by {@link Entry#getKey}
|
||||||
* must be a {@link Streamable} type.
|
* must be a {@link Streamable} type.
|
||||||
|
*
|
||||||
|
* @param <E> the type of entry stored in this set.
|
||||||
*/
|
*/
|
||||||
public class DSet<E extends DSet.Entry>
|
public class DSet<E extends DSet.Entry>
|
||||||
implements Iterable<E>, Streamable, Cloneable
|
implements Iterable<E>, Streamable, Cloneable
|
||||||
@@ -197,10 +198,8 @@ public class DSet<E extends DSet.Entry>
|
|||||||
public Iterator<E> iterator ()
|
public Iterator<E> iterator ()
|
||||||
{
|
{
|
||||||
// the crazy sanity checks
|
// the crazy sanity checks
|
||||||
if (_size < 0 ||_size > _entries.length ||
|
if (_size < 0 || _size > _entries.length || (_size > 0 && _entries[_size-1] == null)) {
|
||||||
(_size > 0 && _entries[_size-1] == null)) {
|
log.warning("DSet in a bad way", "size", _size, "entries", _entries);
|
||||||
log.warning("DSet in a bad way [size=" + _size +
|
|
||||||
", entries=" + StringUtil.toString(_entries) + "].");
|
|
||||||
Thread.dumpStack();
|
Thread.dumpStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,9 +220,8 @@ public class DSet<E extends DSet.Entry>
|
|||||||
throw new ConcurrentModificationException();
|
throw new ConcurrentModificationException();
|
||||||
}
|
}
|
||||||
if (_ssize != _size) {
|
if (_ssize != _size) {
|
||||||
log.warning("Size changed during iteration [ssize=" + _ssize +
|
log.warning("Size changed during iteration", "ssize", _ssize, "nsize", _size,
|
||||||
", nsize=" + _size +
|
"entries", _entries);
|
||||||
", entsries=" + StringUtil.toString(_entries) + "].");
|
|
||||||
Thread.dumpStack();
|
Thread.dumpStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -460,6 +458,7 @@ public class DSet<E extends DSet.Entry>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Used to search for keys. */
|
||||||
protected static class KeyWrapper implements DSet.Entry
|
protected static class KeyWrapper implements DSet.Entry
|
||||||
{
|
{
|
||||||
public KeyWrapper (Comparable key) {
|
public KeyWrapper (Comparable key) {
|
||||||
|
|||||||
@@ -140,5 +140,5 @@ public class DynamicListener
|
|||||||
protected MethodFinder _finder;
|
protected MethodFinder _finder;
|
||||||
|
|
||||||
/** A cache of already resolved methods. */
|
/** A cache of already resolved methods. */
|
||||||
protected HashMap<String,Method> _mcache = new HashMap<String,Method>();
|
protected HashMap<String, Method> _mcache = new HashMap<String, Method>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ import com.samskivert.util.StringUtil;
|
|||||||
* posted to the dobjmgr.
|
* posted to the dobjmgr.
|
||||||
*
|
*
|
||||||
* @see DObjectManager#postEvent
|
* @see DObjectManager#postEvent
|
||||||
|
*
|
||||||
|
* @param <T> the type of entry being handled by this event. This must match the type on the set
|
||||||
|
* that generated this event.
|
||||||
*/
|
*/
|
||||||
public class EntryAddedEvent<T extends DSet.Entry> extends NamedEvent
|
public class EntryAddedEvent<T extends DSet.Entry> extends NamedEvent
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ import static com.threerings.presents.Log.log;
|
|||||||
* posted to the dobjmgr.
|
* posted to the dobjmgr.
|
||||||
*
|
*
|
||||||
* @see DObjectManager#postEvent
|
* @see DObjectManager#postEvent
|
||||||
|
*
|
||||||
|
* @param <T> the type of entry being handled by this event. This must match the type on the set
|
||||||
|
* that generated this event.
|
||||||
*/
|
*/
|
||||||
public class EntryRemovedEvent<T extends DSet.Entry> extends NamedEvent
|
public class EntryRemovedEvent<T extends DSet.Entry> extends NamedEvent
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ import static com.threerings.presents.Log.log;
|
|||||||
* constructed to request the update of an entry and posted to the dobjmgr.
|
* constructed to request the update of an entry and posted to the dobjmgr.
|
||||||
*
|
*
|
||||||
* @see DObjectManager#postEvent
|
* @see DObjectManager#postEvent
|
||||||
|
*
|
||||||
|
* @param <T> the type of entry being handled by this event. This must match the type on the set
|
||||||
|
* that generated this event.
|
||||||
*/
|
*/
|
||||||
public class EntryUpdatedEvent<T extends DSet.Entry> extends NamedEvent
|
public class EntryUpdatedEvent<T extends DSet.Entry> extends NamedEvent
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ package com.threerings.presents.dobj;
|
|||||||
* <p> <b>NOTE:</b> This adapter will receive <em>all</em> Entry events from a DObject it's
|
* <p> <b>NOTE:</b> This adapter will receive <em>all</em> Entry events from a DObject it's
|
||||||
* listening to, so it should check that the event's name matches the field it's interested in
|
* listening to, so it should check that the event's name matches the field it's interested in
|
||||||
* before acting on the event.
|
* before acting on the event.
|
||||||
|
*
|
||||||
|
* @param <T> the type of entry being handled by this listener. This must match the type on the set
|
||||||
|
* that generates the events.
|
||||||
*/
|
*/
|
||||||
public class SetAdapter<T extends DSet.Entry> implements SetListener<T>
|
public class SetAdapter<T extends DSet.Entry> implements SetListener<T>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ package com.threerings.presents.dobj;
|
|||||||
* before acting on the event.
|
* before acting on the event.
|
||||||
*
|
*
|
||||||
* @see DObject#addListener
|
* @see DObject#addListener
|
||||||
|
*
|
||||||
|
* @param <T> the type of entry being handled by this listener. This must match the type on the set
|
||||||
|
* that generates the events.
|
||||||
*/
|
*/
|
||||||
public interface SetListener<T extends DSet.Entry> extends ChangeListener
|
public interface SetListener<T extends DSet.Entry> extends ChangeListener
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ package com.threerings.presents.dobj;
|
|||||||
* @see AttributeChangeListener
|
* @see AttributeChangeListener
|
||||||
* @see SetListener
|
* @see SetListener
|
||||||
* @see OidListListener
|
* @see OidListListener
|
||||||
|
*
|
||||||
|
* @param <T> the type object being subscribed to.
|
||||||
*/
|
*/
|
||||||
public interface Subscriber<T extends DObject>
|
public interface Subscriber<T extends DObject>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ package com.threerings.presents.net;
|
|||||||
|
|
||||||
import com.threerings.presents.dobj.DEvent;
|
import com.threerings.presents.dobj.DEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains an event forwarded from the server.
|
||||||
|
*/
|
||||||
public class EventNotification extends DownstreamMessage
|
public class EventNotification extends DownstreamMessage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
package com.threerings.presents.net;
|
package com.threerings.presents.net;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Communicates failure to subscribe to an object.
|
||||||
|
*/
|
||||||
public class FailureResponse extends DownstreamMessage
|
public class FailureResponse extends DownstreamMessage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ package com.threerings.presents.net;
|
|||||||
|
|
||||||
import com.threerings.presents.dobj.DEvent;
|
import com.threerings.presents.dobj.DEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forwards an event to the server for dispatch.
|
||||||
|
*/
|
||||||
public class ForwardEventRequest extends UpstreamMessage
|
public class ForwardEventRequest extends UpstreamMessage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
package com.threerings.presents.net;
|
package com.threerings.presents.net;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests to end our session with the server.
|
||||||
|
*/
|
||||||
public class LogoffRequest extends UpstreamMessage
|
public class LogoffRequest extends UpstreamMessage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ package com.threerings.presents.net;
|
|||||||
|
|
||||||
import com.threerings.presents.dobj.DObject;
|
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>
|
public class ObjectResponse<T extends DObject>
|
||||||
extends DownstreamMessage
|
extends DownstreamMessage
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,11 +26,13 @@ import java.io.IOException;
|
|||||||
import com.threerings.io.ObjectInputStream;
|
import com.threerings.io.ObjectInputStream;
|
||||||
import com.threerings.io.ObjectOutputStream;
|
import com.threerings.io.ObjectOutputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Let's the server know we're still alive.
|
||||||
|
*/
|
||||||
public class PingRequest extends UpstreamMessage
|
public class PingRequest extends UpstreamMessage
|
||||||
{
|
{
|
||||||
/** The number of milliseconds of idle upstream that are allowed to
|
/** The number of milliseconds of idle upstream that are allowed to elapse before the client
|
||||||
* elapse before the client sends a ping message to the server to let
|
* sends a ping message to the server to let it know that we're still alive. */
|
||||||
* it know that we're still alive. */
|
|
||||||
public static final long PING_INTERVAL = 60 * 1000L;
|
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
|
* Returns a timestamp that was obtained when this packet was encoded by the low-level
|
||||||
* by the low-level networking code.
|
* networking code.
|
||||||
*/
|
*/
|
||||||
public long getPackStamp ()
|
public long getPackStamp ()
|
||||||
{
|
{
|
||||||
@@ -59,8 +61,8 @@ public class PingRequest extends UpstreamMessage
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a timestamp that was obtained when this packet was decoded
|
* Returns a timestamp that was obtained when this packet was decoded by the low-level
|
||||||
* by the low-level networking code.
|
* networking code.
|
||||||
*/
|
*/
|
||||||
public long getUnpackStamp ()
|
public long getUnpackStamp ()
|
||||||
{
|
{
|
||||||
@@ -73,8 +75,8 @@ public class PingRequest extends UpstreamMessage
|
|||||||
public void writeObject (ObjectOutputStream out)
|
public void writeObject (ObjectOutputStream out)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
// grab a timestamp noting when we were encoded into a raw buffer
|
// grab a timestamp noting when we were encoded into a raw buffer for delivery over the
|
||||||
// for delivery over the network
|
// network
|
||||||
_packStamp = System.currentTimeMillis();
|
_packStamp = System.currentTimeMillis();
|
||||||
|
|
||||||
out.defaultWriteObject();
|
out.defaultWriteObject();
|
||||||
@@ -86,8 +88,8 @@ public class PingRequest extends UpstreamMessage
|
|||||||
public void readObject (ObjectInputStream in)
|
public void readObject (ObjectInputStream in)
|
||||||
throws IOException, ClassNotFoundException
|
throws IOException, ClassNotFoundException
|
||||||
{
|
{
|
||||||
// grab a timestamp noting when we were decoded from a raw buffer
|
// grab a timestamp noting when we were decoded from a raw buffer after being received over
|
||||||
// after being received over the network
|
// the network
|
||||||
_unpackStamp = System.currentTimeMillis();
|
_unpackStamp = System.currentTimeMillis();
|
||||||
|
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
@@ -114,9 +116,8 @@ public class PingRequest extends UpstreamMessage
|
|||||||
/** A time stamp obtained when we serialize this object. */
|
/** A time stamp obtained when we serialize this object. */
|
||||||
protected transient long _packStamp;
|
protected transient long _packStamp;
|
||||||
|
|
||||||
/** A time stamp obtained when we unserialize this object (the intent
|
/** A time stamp obtained when we unserialize this object (the intent is to get a timestamp as
|
||||||
* is to get a timestamp as close as possible to when the packet was
|
* close as possible to when the packet was received on the network). */
|
||||||
* received on the network). */
|
|
||||||
protected transient long _unpackStamp;
|
protected transient long _unpackStamp;
|
||||||
|
|
||||||
/** The transport parameters. */
|
/** The transport parameters. */
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ import com.threerings.io.ObjectOutputStream;
|
|||||||
|
|
||||||
import static com.threerings.presents.Log.log;
|
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
|
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
|
* Constructs a pong response which will use the supplied ping time to establish the end-to-end
|
||||||
* establish the end-to-end processing delay introduced by the server.
|
* processing delay introduced by the server.
|
||||||
*/
|
*/
|
||||||
public PongResponse (long pingStamp, Transport transport)
|
public PongResponse (long pingStamp, Transport transport)
|
||||||
{
|
{
|
||||||
// save this for when we are serialized in preparation for
|
// save this for when we are serialized in preparation for delivery over the network
|
||||||
// delivery over the network
|
|
||||||
_pingStamp = pingStamp;
|
_pingStamp = pingStamp;
|
||||||
_transport = transport;
|
_transport = transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the time at which this packet was packed for delivery in
|
* Returns the time at which this packet was packed for delivery in the time frame of the
|
||||||
* the time frame of the server that sent the packet.
|
* server that sent the packet.
|
||||||
*/
|
*/
|
||||||
public long getPackStamp ()
|
public long getPackStamp ()
|
||||||
{
|
{
|
||||||
@@ -60,9 +63,9 @@ public class PongResponse extends DownstreamMessage
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of milliseconds that elapsed between the time
|
* Returns the number of milliseconds that elapsed between the time that the ping which
|
||||||
* that the ping which instigated this pong was read from the network
|
* instigated this pong was read from the network and the time that this pong was written to
|
||||||
* and the time that this pong was written to the network.
|
* the network.
|
||||||
*/
|
*/
|
||||||
public int getProcessDelay ()
|
public int getProcessDelay ()
|
||||||
{
|
{
|
||||||
@@ -70,8 +73,8 @@ public class PongResponse extends DownstreamMessage
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a timestamp that was obtained when this packet was decoded
|
* Returns a timestamp that was obtained when this packet was decoded by the low-level
|
||||||
* by the low-level networking code.
|
* networking code.
|
||||||
*/
|
*/
|
||||||
public long getUnpackStamp ()
|
public long getUnpackStamp ()
|
||||||
{
|
{
|
||||||
@@ -87,8 +90,7 @@ public class PongResponse extends DownstreamMessage
|
|||||||
// make a note of the time at which we were packed
|
// make a note of the time at which we were packed
|
||||||
_packStamp = System.currentTimeMillis();
|
_packStamp = System.currentTimeMillis();
|
||||||
|
|
||||||
// the time spent between unpacking the ping and packing the pong
|
// the time spent between unpacking the ping and packing the pong is the processing delay
|
||||||
// is the processing delay
|
|
||||||
if (_pingStamp == 0L) {
|
if (_pingStamp == 0L) {
|
||||||
log.warning("Pong response written that was not constructed " +
|
log.warning("Pong response written that was not constructed " +
|
||||||
"with a valid ping stamp [rsp=" + this + "].");
|
"with a valid ping stamp [rsp=" + this + "].");
|
||||||
@@ -106,8 +108,8 @@ public class PongResponse extends DownstreamMessage
|
|||||||
public void readObject (ObjectInputStream in)
|
public void readObject (ObjectInputStream in)
|
||||||
throws IOException, ClassNotFoundException
|
throws IOException, ClassNotFoundException
|
||||||
{
|
{
|
||||||
// grab a timestamp noting when we were decoded from a raw buffer
|
// grab a timestamp noting when we were decoded from a raw buffer after being received over
|
||||||
// after being received over the network
|
// the network
|
||||||
_unpackStamp = System.currentTimeMillis();
|
_unpackStamp = System.currentTimeMillis();
|
||||||
|
|
||||||
in.defaultReadObject();
|
in.defaultReadObject();
|
||||||
@@ -131,23 +133,19 @@ public class PongResponse extends DownstreamMessage
|
|||||||
return "[type=PONG, msgid=" + messageId + ", transport=" + _transport + "]";
|
return "[type=PONG, msgid=" + messageId + ", transport=" + _transport + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The ping unpack stamp provided at construct time to this pong
|
/** The ping unpack stamp provided at construct time to this pong response; only valid on the
|
||||||
* response; only valid on the sending process, not the receiving
|
* sending process, not the receiving process. */
|
||||||
* process. */
|
|
||||||
protected transient long _pingStamp;
|
protected transient long _pingStamp;
|
||||||
|
|
||||||
/** The timestamp obtained immediately before this packet was sent out
|
/** The timestamp obtained immediately before this packet was sent out over the network. */
|
||||||
* over the network. */
|
|
||||||
protected long _packStamp;
|
protected long _packStamp;
|
||||||
|
|
||||||
/** The delay in milliseconds between the time that the ping request
|
/** The delay in milliseconds between the time that the ping request was read from the network
|
||||||
* was read from the network and the time the pong response was
|
* and the time the pong response was written to the network. */
|
||||||
* written to the network. */
|
|
||||||
protected int _processDelay;
|
protected int _processDelay;
|
||||||
|
|
||||||
/** A time stamp obtained when we unserialize this object (the intent
|
/** A time stamp obtained when we unserialize this object (the intent is to get a timestamp as
|
||||||
* is to get a timestamp as close as possible to when the packet was
|
* close as possible to when the packet was received on the network). */
|
||||||
* received on the network). */
|
|
||||||
protected transient long _unpackStamp;
|
protected transient long _unpackStamp;
|
||||||
|
|
||||||
/** The transport parameters. */
|
/** The transport parameters. */
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
package com.threerings.presents.net;
|
package com.threerings.presents.net;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests to subscribe to a particular distributed object.
|
||||||
|
*/
|
||||||
public class SubscribeRequest extends UpstreamMessage
|
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
|
* 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
|
* define independent streams for ordered transport), and may eventually include message priority,
|
||||||
* priority, etc.
|
* etc.
|
||||||
*/
|
*/
|
||||||
public class Transport
|
public class Transport
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
package com.threerings.presents.net;
|
package com.threerings.presents.net;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests to end a subscription to a particular distributed object.
|
||||||
|
*/
|
||||||
public class UnsubscribeRequest extends UpstreamMessage
|
public class UnsubscribeRequest extends UpstreamMessage
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ package com.threerings.presents.net;
|
|||||||
|
|
||||||
import com.threerings.util.Name;
|
import com.threerings.util.Name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extends the basic credentials with a password.
|
||||||
|
*/
|
||||||
public class UsernamePasswordCreds extends Credentials
|
public class UsernamePasswordCreds extends Credentials
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ public abstract class PeerManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Tuple<String,Integer> key = new Tuple<String,Integer>(nodeName, remoteOid);
|
final Tuple<String, Integer> key = new Tuple<String, Integer>(nodeName, remoteOid);
|
||||||
if (_proxies.containsKey(key)) {
|
if (_proxies.containsKey(key)) {
|
||||||
String errmsg = "Cannot proxy already proxied object [key=" + key + "].";
|
String errmsg = "Cannot proxy already proxied object [key=" + key + "].";
|
||||||
listener.requestFailed(new ObjectAccessException(errmsg));
|
listener.requestFailed(new ObjectAccessException(errmsg));
|
||||||
@@ -387,7 +387,7 @@ public abstract class PeerManager
|
|||||||
peer.getDObjectManager().subscribeToObject(remoteOid, new Subscriber<T>() {
|
peer.getDObjectManager().subscribeToObject(remoteOid, new Subscriber<T>() {
|
||||||
public void objectAvailable (T object) {
|
public void objectAvailable (T object) {
|
||||||
// make a note of this proxy mapping
|
// make a note of this proxy mapping
|
||||||
_proxies.put(key, new Tuple<Subscriber<?>,DObject>(this, object));
|
_proxies.put(key, new Tuple<Subscriber<?>, DObject>(this, object));
|
||||||
// map the object into our local oid space
|
// map the object into our local oid space
|
||||||
_omgr.registerProxyObject(object, peer.getDObjectManager());
|
_omgr.registerProxyObject(object, peer.getDObjectManager());
|
||||||
// then tell the caller about the (now remapped) oid
|
// then tell the caller about the (now remapped) oid
|
||||||
@@ -405,8 +405,8 @@ public abstract class PeerManager
|
|||||||
*/
|
*/
|
||||||
public void unproxyRemoteObject (String nodeName, int remoteOid)
|
public void unproxyRemoteObject (String nodeName, int remoteOid)
|
||||||
{
|
{
|
||||||
Tuple<String,Integer> key = new Tuple<String,Integer>(nodeName, remoteOid);
|
Tuple<String, Integer> key = new Tuple<String, Integer>(nodeName, remoteOid);
|
||||||
Tuple<Subscriber<?>,DObject> bits = _proxies.remove(key);
|
Tuple<Subscriber<?>, DObject> bits = _proxies.remove(key);
|
||||||
if (bits == null) {
|
if (bits == null) {
|
||||||
log.warning("Requested to clear unknown proxy [key=" + key + "].");
|
log.warning("Requested to clear unknown proxy [key=" + key + "].");
|
||||||
return;
|
return;
|
||||||
@@ -807,7 +807,7 @@ public abstract class PeerManager
|
|||||||
_nodes = _noderepo.loadNodes();
|
_nodes = _noderepo.loadNodes();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void handleSuccess() {
|
public void handleSuccess () {
|
||||||
for (NodeRecord record : _nodes) {
|
for (NodeRecord record : _nodes) {
|
||||||
if (record.nodeName.equals(_nodeName)) {
|
if (record.nodeName.equals(_nodeName)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -1202,7 +1202,7 @@ public abstract class PeerManager
|
|||||||
protected String _nodeName, _sharedSecret;
|
protected String _nodeName, _sharedSecret;
|
||||||
protected NodeRecord _self;
|
protected NodeRecord _self;
|
||||||
protected NodeObject _nodeobj;
|
protected NodeObject _nodeobj;
|
||||||
protected Map<String,PeerNode> _peers = Maps.newHashMap();
|
protected Map<String, PeerNode> _peers = Maps.newHashMap();
|
||||||
|
|
||||||
/** Used to resolve dependencies in unserialized {@link NodeAction} instances. */
|
/** Used to resolve dependencies in unserialized {@link NodeAction} instances. */
|
||||||
protected Injector _injector;
|
protected Injector _injector;
|
||||||
@@ -1211,7 +1211,8 @@ public abstract class PeerManager
|
|||||||
protected ArrayIntSet _suboids = new ArrayIntSet();
|
protected ArrayIntSet _suboids = new ArrayIntSet();
|
||||||
|
|
||||||
/** Contains a mapping of proxied objects to subscriber instances. */
|
/** Contains a mapping of proxied objects to subscriber instances. */
|
||||||
protected Map<Tuple<String,Integer>,Tuple<Subscriber<?>,DObject>> _proxies = Maps.newHashMap();
|
protected Map<Tuple<String, Integer>, Tuple<Subscriber<?>, DObject>> _proxies =
|
||||||
|
Maps.newHashMap();
|
||||||
|
|
||||||
/** Our stale cache observers. */
|
/** Our stale cache observers. */
|
||||||
protected Map<String, ObserverList<StaleCacheObserver>> _cacheobs = Maps.newHashMap();
|
protected Map<String, ObserverList<StaleCacheObserver>> _cacheobs = Maps.newHashMap();
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public abstract class Authenticator
|
|||||||
|
|
||||||
invoker.postUnit(new Invoker.Unit("authenticateConnection") {
|
invoker.postUnit(new Invoker.Unit("authenticateConnection") {
|
||||||
@Override
|
@Override
|
||||||
public boolean invoke() {
|
public boolean invoke () {
|
||||||
try {
|
try {
|
||||||
processAuthentication(conn, rsp);
|
processAuthentication(conn, rsp);
|
||||||
} catch (Exception e) { // Persistence or Runtime
|
} catch (Exception e) { // Persistence or Runtime
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import com.threerings.presents.net.AuthRequest;
|
|||||||
public interface ClientFactory
|
public interface ClientFactory
|
||||||
{
|
{
|
||||||
/** The default client factory. */
|
/** The default client factory. */
|
||||||
public static ClientFactory DEFAULT = new ClientFactory () {
|
public static ClientFactory DEFAULT = new ClientFactory() {
|
||||||
public Class<? extends PresentsClient> getClientClass (AuthRequest areq) {
|
public Class<? extends PresentsClient> getClientClass (AuthRequest areq) {
|
||||||
return PresentsClient.class;
|
return PresentsClient.class;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,10 @@ import com.threerings.presents.data.ClientObject;
|
|||||||
import com.threerings.presents.net.AuthRequest;
|
import com.threerings.presents.net.AuthRequest;
|
||||||
import com.threerings.presents.net.AuthResponse;
|
import com.threerings.presents.net.AuthResponse;
|
||||||
import com.threerings.presents.net.Credentials;
|
import com.threerings.presents.net.Credentials;
|
||||||
import com.threerings.presents.server.net.*;
|
import com.threerings.presents.server.net.AuthingConnection;
|
||||||
|
import com.threerings.presents.server.net.Connection;
|
||||||
|
import com.threerings.presents.server.net.ConnectionManager;
|
||||||
|
import com.threerings.presents.server.net.ConnectionObserver;
|
||||||
|
|
||||||
import static com.threerings.presents.Log.log;
|
import static com.threerings.presents.Log.log;
|
||||||
|
|
||||||
@@ -323,7 +326,7 @@ public class ClientManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renames a currently connected client from <code>oldname</code> to <code>newname</code>
|
* Renames a currently connected client from <code>oldname</code> to <code>newname</code>.
|
||||||
*
|
*
|
||||||
* @return true if the client was found and renamed.
|
* @return true if the client was found and renamed.
|
||||||
*/
|
*/
|
||||||
@@ -548,16 +551,16 @@ public class ClientManager
|
|||||||
protected Injector _injector;
|
protected Injector _injector;
|
||||||
|
|
||||||
/** A mapping from auth username to client instances. */
|
/** A mapping from auth username to client instances. */
|
||||||
protected Map<Name,PresentsClient> _usermap = Maps.newHashMap();
|
protected Map<Name, PresentsClient> _usermap = Maps.newHashMap();
|
||||||
|
|
||||||
/** A mapping from connections to client instances. */
|
/** A mapping from connections to client instances. */
|
||||||
protected Map<Connection,PresentsClient> _conmap = Maps.newHashMap();
|
protected Map<Connection, PresentsClient> _conmap = Maps.newHashMap();
|
||||||
|
|
||||||
/** A mapping from usernames to client object instances. */
|
/** A mapping from usernames to client object instances. */
|
||||||
protected Map<Name,ClientObject> _objmap = Maps.newHashMap();
|
protected Map<Name, ClientObject> _objmap = Maps.newHashMap();
|
||||||
|
|
||||||
/** A mapping of pending client resolvers. */
|
/** A mapping of pending client resolvers. */
|
||||||
protected Map<Name,ClientResolver> _penders = Maps.newHashMap();
|
protected Map<Name, ClientResolver> _penders = Maps.newHashMap();
|
||||||
|
|
||||||
/** Lets us know what sort of client classes to use. */
|
/** Lets us know what sort of client classes to use. */
|
||||||
protected ClientFactory _factory = ClientFactory.DEFAULT;
|
protected ClientFactory _factory = ClientFactory.DEFAULT;
|
||||||
|
|||||||
Reference in New Issue
Block a user