Support bureau death
* New static method to extract a bureau id from a username * Inject the client manager in the registry and tack all bureau sessions * Listen for sessions ending and call the clientDestroyed method * Actually clear our the agents and remove the bureau from the map when the client is destroyed (this will trigger a new launch for the next agent request in that bureau) * Deprecate addClientFactory * Added lookup function to retrieve a bureau session by bureau id so that client code will be able to kill specific bureau sessions git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5238 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -29,6 +29,9 @@ import com.threerings.util.Name;
|
||||
*/
|
||||
public class BureauCredentials extends Credentials
|
||||
{
|
||||
public static String PREFIX = "@@bureau:";
|
||||
public static String SUFFIX = "@@";
|
||||
|
||||
/**
|
||||
* The token to pass to the server when logging in. This is usually just passed to the bureau
|
||||
* on the command line to guard against outside connections being established.
|
||||
@@ -46,7 +49,22 @@ public class BureauCredentials extends Credentials
|
||||
public static boolean isBureau (Name name)
|
||||
{
|
||||
String normal = name.getNormal();
|
||||
return normal.startsWith("@@bureau:") && normal.endsWith("@@");
|
||||
return normal.startsWith(PREFIX) && normal.endsWith(SUFFIX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the buerauId from the name that we generate.
|
||||
*/
|
||||
public static String extractBureauId (Name name)
|
||||
{
|
||||
String normal = name.getNormal();
|
||||
int prefixPos = normal.indexOf(PREFIX);
|
||||
int suffixPos = normal.lastIndexOf(SUFFIX);
|
||||
if (prefixPos != 0 || suffixPos != normal.length() - SUFFIX.length()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return normal.substring(prefixPos + PREFIX.length(), suffixPos);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user