Chipping away at proper type safety for all of the Narya code.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4232 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -40,7 +40,7 @@ import com.threerings.presents.dobj.Subscriber;
|
||||
* appropriately.
|
||||
*/
|
||||
public class ClientResolver extends Invoker.Unit
|
||||
implements Subscriber
|
||||
implements Subscriber<ClientObject>
|
||||
{
|
||||
/**
|
||||
* Initiailizes this instance.
|
||||
@@ -70,11 +70,11 @@ public class ClientResolver extends Invoker.Unit
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void objectAvailable (DObject object)
|
||||
public void objectAvailable (ClientObject object)
|
||||
{
|
||||
// we've got our object, so shunt ourselves over to the invoker
|
||||
// thread to perform database loading
|
||||
_clobj = (ClientObject)object;
|
||||
_clobj = object;
|
||||
PresentsServer.invoker.postUnit(this);
|
||||
|
||||
// we no longer need to be a subscriber of the object now that it
|
||||
@@ -121,10 +121,8 @@ public class ClientResolver extends Invoker.Unit
|
||||
PresentsServer.clmgr.mapClientObject(_username, _clobj);
|
||||
|
||||
// and let the listeners in on the secret as well
|
||||
int lcount = _listeners.size();
|
||||
for (int i = 0; i < lcount; i++) {
|
||||
ClientResolutionListener crl = (ClientResolutionListener)
|
||||
_listeners.get(i);
|
||||
for (int ii = 0, ll = _listeners.size(); ii < ll; ii++) {
|
||||
ClientResolutionListener crl = _listeners.get(ii);
|
||||
try {
|
||||
// add a reference for each listener
|
||||
_clobj.reference();
|
||||
@@ -173,10 +171,8 @@ public class ClientResolver extends Invoker.Unit
|
||||
*/
|
||||
protected void reportFailure (Exception cause)
|
||||
{
|
||||
int lcount = _listeners.size();
|
||||
for (int i = 0; i < lcount; i++) {
|
||||
ClientResolutionListener crl = (ClientResolutionListener)
|
||||
_listeners.get(i);
|
||||
for (int ii = 0, ll = _listeners.size(); ii < ll; ii++) {
|
||||
ClientResolutionListener crl = _listeners.get(ii);
|
||||
try {
|
||||
crl.resolutionFailed(_username, cause);
|
||||
} catch (Exception e) {
|
||||
@@ -193,7 +189,8 @@ public class ClientResolver extends Invoker.Unit
|
||||
protected Name _username;
|
||||
|
||||
/** The entities to notify of success or failure. */
|
||||
protected ArrayList _listeners = new ArrayList();
|
||||
protected ArrayList<ClientResolutionListener> _listeners =
|
||||
new ArrayList<ClientResolutionListener>();
|
||||
|
||||
/** The resolving client object. */
|
||||
protected ClientObject _clobj;
|
||||
|
||||
@@ -512,7 +512,7 @@ public class PresentsClient
|
||||
*/
|
||||
public synchronized void unmapSubscrip (int oid)
|
||||
{
|
||||
DObject object = (DObject)_subscrips.remove(oid);
|
||||
DObject object = _subscrips.remove(oid);
|
||||
if (object != null) {
|
||||
object.removeSubscriber(this);
|
||||
} else {
|
||||
@@ -527,8 +527,7 @@ public class PresentsClient
|
||||
*/
|
||||
protected void clearSubscrips (boolean verbose)
|
||||
{
|
||||
for (Iterator itr = _subscrips.elements(); itr.hasNext(); ) {
|
||||
DObject object = (DObject)itr.next();
|
||||
for (DObject object : _subscrips.values()) {
|
||||
if (verbose) {
|
||||
Log.info("Clearing subscription [client=" + this +
|
||||
", obj=" + object.getOid() + "].");
|
||||
@@ -751,8 +750,7 @@ public class PresentsClient
|
||||
|
||||
// we dispatch to a message dispatcher that is specialized for the
|
||||
// particular class of message that we received
|
||||
MessageDispatcher disp = (MessageDispatcher)
|
||||
_disps.get(message.getClass());
|
||||
MessageDispatcher disp = _disps.get(message.getClass());
|
||||
if (disp == null) {
|
||||
Log.warning("No dispatcher for message [msg=" + message + "].");
|
||||
return;
|
||||
@@ -957,7 +955,7 @@ public class PresentsClient
|
||||
protected Name _username;
|
||||
protected Connection _conn;
|
||||
protected ClientObject _clobj;
|
||||
protected HashIntMap _subscrips = new HashIntMap();
|
||||
protected HashIntMap<DObject> _subscrips = new HashIntMap<DObject>();
|
||||
protected ClassLoader _loader;
|
||||
|
||||
/** The time at which this client started their session. */
|
||||
@@ -981,7 +979,8 @@ public class PresentsClient
|
||||
protected int _messagesDropped;
|
||||
|
||||
/** A mapping of message dispatchers. */
|
||||
protected static HashMap _disps = new HashMap();
|
||||
protected static HashMap<Class<?>,MessageDispatcher> _disps =
|
||||
new HashMap<Class<?>,MessageDispatcher>();
|
||||
|
||||
/** The amount of time after disconnection a user is allowed before
|
||||
* their session is forcibly ended. */
|
||||
|
||||
@@ -396,9 +396,11 @@ public class ConnectionManager extends LoopingThread
|
||||
}
|
||||
|
||||
// send any messages that are waiting on the outgoing queue
|
||||
Tuple tup;
|
||||
while ((tup = (Tuple)_outq.getNonBlocking()) != null) {
|
||||
Connection conn = (Connection)tup.left;
|
||||
Object obj;
|
||||
while ((obj = _outq.getNonBlocking()) != null) {
|
||||
@SuppressWarnings("unchecked") Tuple<Connection,byte[]> tup =
|
||||
(Tuple<Connection,byte[]>)obj;
|
||||
Connection conn = tup.left;
|
||||
|
||||
// if an overflow queue exists for this client, go ahead and
|
||||
// slap the message on there because we can't send it until
|
||||
@@ -416,7 +418,7 @@ public class ConnectionManager extends LoopingThread
|
||||
}
|
||||
|
||||
// otherwise write the message out to the client directly
|
||||
writeMessage(conn, (byte[])tup.right, _oflowHandler);
|
||||
writeMessage(conn, tup.right, _oflowHandler);
|
||||
}
|
||||
|
||||
// check for connections that have completed authentication
|
||||
@@ -735,7 +737,7 @@ public class ConnectionManager extends LoopingThread
|
||||
// data.length + " bytes.");
|
||||
|
||||
// and slap both on the queue
|
||||
_outq.append(new Tuple(conn, data));
|
||||
_outq.append(new Tuple<Connection,byte[]>(conn, data));
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.warning("Failure flattening message [conn=" + conn +
|
||||
@@ -791,7 +793,7 @@ public class ConnectionManager extends LoopingThread
|
||||
* higher levels so that further messages are not queued up for the
|
||||
* unresponsive client.
|
||||
*/
|
||||
protected class OverflowQueue extends ArrayList
|
||||
protected class OverflowQueue extends ArrayList<byte[]>
|
||||
implements PartialWriteHandler
|
||||
{
|
||||
/** The connection for which we're managing overflow. */
|
||||
@@ -841,7 +843,7 @@ public class ConnectionManager extends LoopingThread
|
||||
}
|
||||
|
||||
while (size() > 0) {
|
||||
byte[] data = (byte[])remove(0);
|
||||
byte[] data = remove(0);
|
||||
// if any of these messages are partially written, we have
|
||||
// to stop and wait for the next tick
|
||||
_msgs++;
|
||||
|
||||
Reference in New Issue
Block a user