* Remove old CAPS http listeners when a client logs out from a scene

* Not yet removing listeners when a client leaves a region without logging out
0.6.0-stable
Justin Clarke Casey 2008-03-25 17:08:20 +00:00
parent 3c3f1bc69a
commit 2517fe7acd
2 changed files with 41 additions and 22 deletions

View File

@ -68,15 +68,15 @@ namespace OpenSim.Region.Capabilities
private string m_capsObjectPath; private string m_capsObjectPath;
public string CapsObjectPath { get { return m_capsObjectPath; } } public string CapsObjectPath { get { return m_capsObjectPath; } }
private string m_requestPath = "0000/"; private static readonly string m_requestPath = "0000/";
private string m_mapLayerPath = "0001/"; private static readonly string m_mapLayerPath = "0001/";
private string m_newInventory = "0002/"; private static readonly string m_newInventory = "0002/";
//private string m_requestTexture = "0003/"; //private static readonly string m_requestTexture = "0003/";
private string m_notecardUpdatePath = "0004/"; private static readonly string m_notecardUpdatePath = "0004/";
private string m_notecardTaskUpdatePath = "0005/"; private static readonly string m_notecardTaskUpdatePath = "0005/";
private string m_fetchInventoryPath = "0006/"; private static readonly string m_fetchInventoryPath = "0006/";
private string m_parcelVoiceInfoRequestPath = "0007/"; private static readonly string m_parcelVoiceInfoRequestPath = "0007/";
private string m_provisionVoiceAccountRequestPath = "0008/"; private static readonly string m_provisionVoiceAccountRequestPath = "0008/";
//private string eventQueue = "0100/"; //private string eventQueue = "0100/";
private BaseHttpServer m_httpListener; private BaseHttpServer m_httpListener;
@ -94,7 +94,6 @@ namespace OpenSim.Region.Capabilities
// //
public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null;
public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath,
LLUUID agent, bool dumpAssetsToFile) LLUUID agent, bool dumpAssetsToFile)
{ {
@ -108,20 +107,18 @@ namespace OpenSim.Region.Capabilities
} }
/// <summary> /// <summary>
/// /// Register all CAPS http service handlers
/// </summary> /// </summary>
public void RegisterHandlers() public void RegisterHandlers()
{ {
DeregisterHandlers();
string capsBase = "/CAPS/" + m_capsObjectPath; string capsBase = "/CAPS/" + m_capsObjectPath;
try try
{ {
m_httpListener.RemoveStreamHandler("POST", capsBase + m_mapLayerPath);
m_httpListener.AddStreamHandler( m_httpListener.AddStreamHandler(
new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath, new LLSDStreamhandler<LLSDMapRequest, LLSDMapLayerResponse>("POST", capsBase + m_mapLayerPath, GetMapLayer));
GetMapLayer));
m_httpListener.RemoveStreamHandler("POST", capsBase + m_newInventory);
m_httpListener.AddStreamHandler( m_httpListener.AddStreamHandler(
new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST", new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>("POST",
capsBase + m_newInventory, capsBase + m_newInventory,
@ -147,6 +144,28 @@ namespace OpenSim.Region.Capabilities
} }
} }
/// <summary>
/// Remove all CAPS service handlers.
///
/// FIXME: Would be much nicer to remove and all paths to a single list. However, this is a little awkward
/// than it could be as we set up some handlers differently (legacy and non-legacy)
/// </summary>
/// <param name="httpListener"></param>
/// <param name="path"></param>
/// <param name="restMethod"></param>
public void DeregisterHandlers()
{
string capsBase = "/CAPS/" + m_capsObjectPath;
m_httpListener.RemoveStreamHandler("POST", capsBase + m_mapLayerPath);
m_httpListener.RemoveStreamHandler("POST", capsBase + m_newInventory);
m_httpListener.RemoveStreamHandler("POST", capsBase + m_requestPath);
m_httpListener.RemoveStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath);
m_httpListener.RemoveStreamHandler("POST", capsBase + m_provisionVoiceAccountRequestPath);
m_httpListener.RemoveStreamHandler("POST", capsBase + m_notecardUpdatePath);
m_httpListener.RemoveStreamHandler("POST", capsBase + m_notecardTaskUpdatePath);
m_httpListener.RemoveStreamHandler("POST", capsBase + m_fetchInventoryPath);
}
//[Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")] //[Obsolete("Use BaseHttpServer.AddStreamHandler(new LLSDStreamHandler( LLSDMethod delegate )) instead.")]
//Commented out the obsolete as at this time the first caps request can not use the new Caps method //Commented out the obsolete as at this time the first caps request can not use the new Caps method
@ -154,7 +173,6 @@ namespace OpenSim.Region.Capabilities
private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod) private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod)
{ {
string capsBase = "/CAPS/" + m_capsObjectPath; string capsBase = "/CAPS/" + m_capsObjectPath;
httpListener.RemoveStreamHandler("POST", capsBase + path);
httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod));
} }

View File

@ -1463,7 +1463,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
/// <summary> /// <summary>
/// Remove the given presence from the scene. /// Remove the given client from the scene.
/// </summary> /// </summary>
/// <param name="agentID"></param> /// <param name="agentID"></param>
public override void RemoveClient(LLUUID agentID) public override void RemoveClient(LLUUID agentID)
@ -1496,6 +1496,7 @@ namespace OpenSim.Region.Environment.Scenes
if (m_capsHandlers.ContainsKey(agentID)) if (m_capsHandlers.ContainsKey(agentID))
{ {
m_capsHandlers[agentID].DeregisterHandlers();
m_capsHandlers.Remove(agentID); m_capsHandlers.Remove(agentID);
} }
} }