com.threerings.nio.conman
Class ConnectionManager.OverflowQueue
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<byte[]>
com.threerings.nio.conman.ConnectionManager.OverflowQueue
- All Implemented Interfaces:
- ConnectionManager.PartialWriteHandler, Serializable, Cloneable, Iterable<byte[]>, Collection<byte[]>, List<byte[]>, RandomAccess
- Enclosing class:
- ConnectionManager
protected class ConnectionManager.OverflowQueue
- extends ArrayList<byte[]>
- implements ConnectionManager.PartialWriteHandler
Used to handle messages for a client whose network buffer has filled up because their
outgoing network buffer has filled up. This can happen if the client receives many messages
in rapid succession or if they receive very large messages or if they become unresponsive
and stop acknowledging network packets sent by the server. We want to accomodate the first
to circumstances and recognize the third as quickly as possible so that we can disconnect
the client and propagate that information up to the higher levels so that further messages
are not queued up for the unresponsive client.
- See Also:
- Serialized Form
|
Field Summary |
protected int |
_msgs
A couple of counters. |
protected ByteBuffer |
_partial
The remains of a message that was only partially written on its first attempt. |
protected int |
_partials
A couple of counters. |
Connection |
conn
The connection for which we're managing overflow. |
| Methods inherited from class java.util.ArrayList |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
conn
public Connection conn
- The connection for which we're managing overflow.
_partial
protected ByteBuffer _partial
- The remains of a message that was only partially written on its first attempt.
_msgs
protected int _msgs
- A couple of counters.
_partials
protected int _partials
- A couple of counters.
ConnectionManager.OverflowQueue
public ConnectionManager.OverflowQueue(Connection conn,
ByteBuffer message)
- Creates a new overflow queue for the supplied connection and with the supplied initial
partial message.
writeOverflowMessages
public boolean writeOverflowMessages(long iterStamp)
throws IOException
- Called each time through the
ConnectionManager.iterate() loop, this attempts to
send any remaining partial message and all subsequent messages in the overflow queue.
- Returns:
- true if all messages in this queue were successfully sent, false if there
remains data to be sent on the next loop.
- Throws:
IOException - if an error occurs writing data to the connection or if we have been
unable to write any data to the connection for ten seconds.
handlePartialWrite
public void handlePartialWrite(Connection wconn,
ByteBuffer buffer)
- Specified by:
handlePartialWrite in interface ConnectionManager.PartialWriteHandler
toString
public String toString()
- Overrides:
toString in class AbstractCollection<byte[]>