More custom classloader support. We now have a proof-of-concept working so

it's unlikely that the rabbit hole will surprise us with further depth.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3269 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2004-12-10 02:54:26 +00:00
parent c92a922678
commit a6d7764e29
5 changed files with 87 additions and 30 deletions
@@ -1,5 +1,5 @@
//
// $Id: PresentsClient.java,v 1.69 2004/10/27 01:27:44 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -147,6 +147,19 @@ public class PresentsClient
return (conn == null) ? null : conn.getInetAddress();
}
/**
* Configures this client with a custom class loader that will be used
* when unserializing classes from the network.
*/
public void setClassLoader (ClassLoader loader)
{
_loader = loader;
Connection conn = getConnection();
if (conn != null) {
conn.setClassLoader(loader);
}
}
/**
* <em>Danger:</em> this method is not for general consumption. This
* changes the username of the client, but should only be done very
@@ -660,6 +673,11 @@ public class PresentsClient
// a connection rather than clearing one out)
if (_conn != null) {
_conn.setMessageHandler(this);
// configure any active custom class loader
if (_loader != null) {
_conn.setClassLoader(_loader);
}
}
// make a note that our network status changed
@@ -897,8 +915,7 @@ public class PresentsClient
protected Connection _conn;
protected ClientObject _clobj;
protected HashIntMap _subscrips = new HashIntMap();
protected static HashMap _disps = new HashMap();
protected ClassLoader _loader;
/** The time at which this client started their session. */
protected long _sessionStamp;
@@ -916,6 +933,9 @@ public class PresentsClient
protected int _messagesOut;
protected int _messagesDropped;
/** A mapping of message dispatchers. */
protected static HashMap _disps = new HashMap();
/** The amount of time after disconnection a user is allowed before
* their session is forcibly ended. */
protected static final long FLUSH_TIME = 7 * 60 * 1000L;