From 2517fe7acd97fd93a73d936664415008c0099b00 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 25 Mar 2008 17:08:20 +0000 Subject: [PATCH] * 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 --- .../Communications/Capabilities/Caps.cs | 60 ++++++++++++------- OpenSim/Region/Environment/Scenes/Scene.cs | 3 +- 2 files changed, 41 insertions(+), 22 deletions(-) diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index cac05710d2..c9e7507726 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -68,15 +68,15 @@ namespace OpenSim.Region.Capabilities private string m_capsObjectPath; public string CapsObjectPath { get { return m_capsObjectPath; } } - private string m_requestPath = "0000/"; - private string m_mapLayerPath = "0001/"; - private string m_newInventory = "0002/"; - //private string m_requestTexture = "0003/"; - private string m_notecardUpdatePath = "0004/"; - private string m_notecardTaskUpdatePath = "0005/"; - private string m_fetchInventoryPath = "0006/"; - private string m_parcelVoiceInfoRequestPath = "0007/"; - private string m_provisionVoiceAccountRequestPath = "0008/"; + private static readonly string m_requestPath = "0000/"; + private static readonly string m_mapLayerPath = "0001/"; + private static readonly string m_newInventory = "0002/"; + //private static readonly string m_requestTexture = "0003/"; + private static readonly string m_notecardUpdatePath = "0004/"; + private static readonly string m_notecardTaskUpdatePath = "0005/"; + private static readonly string m_fetchInventoryPath = "0006/"; + private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; + private static readonly string m_provisionVoiceAccountRequestPath = "0008/"; //private string eventQueue = "0100/"; private BaseHttpServer m_httpListener; @@ -94,7 +94,6 @@ namespace OpenSim.Region.Capabilities // public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null; - public Caps(AssetCache assetCache, BaseHttpServer httpServer, string httpListen, uint httpPort, string capsPath, LLUUID agent, bool dumpAssetsToFile) { @@ -108,25 +107,23 @@ namespace OpenSim.Region.Capabilities } /// - /// + /// Register all CAPS http service handlers /// public void RegisterHandlers() { - string capsBase = "/CAPS/" + m_capsObjectPath; + DeregisterHandlers(); + + string capsBase = "/CAPS/" + m_capsObjectPath; try - { - m_httpListener.RemoveStreamHandler("POST", capsBase + m_mapLayerPath); + { m_httpListener.AddStreamHandler( - new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, - GetMapLayer)); - - m_httpListener.RemoveStreamHandler("POST", capsBase + m_newInventory); + new LLSDStreamhandler("POST", capsBase + m_mapLayerPath, GetMapLayer)); m_httpListener.AddStreamHandler( new LLSDStreamhandler("POST", capsBase + m_newInventory, NewAgentInventoryRequest)); - + // m_httpListener.AddStreamHandler( // new LLSDStreamhandler("POST", // capsBase + m_fetchInventory, @@ -147,14 +144,35 @@ namespace OpenSim.Region.Capabilities } } + /// + /// 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) + /// + /// + /// + /// + 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.")] //Commented out the obsolete as at this time the first caps request can not use the new Caps method //as the sent type is a array and not a map and the deserialising doesn't deal properly with arrays. private void AddLegacyCapsHandler(BaseHttpServer httpListener, string path, RestMethod restMethod) { - string capsBase = "/CAPS/" + m_capsObjectPath; - httpListener.RemoveStreamHandler("POST", capsBase + path); + string capsBase = "/CAPS/" + m_capsObjectPath; httpListener.AddStreamHandler(new RestStreamHandler("POST", capsBase + path, restMethod)); } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index bba5ae1252..75f8c23c0c 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1463,7 +1463,7 @@ namespace OpenSim.Region.Environment.Scenes } /// - /// Remove the given presence from the scene. + /// Remove the given client from the scene. /// /// public override void RemoveClient(LLUUID agentID) @@ -1496,6 +1496,7 @@ namespace OpenSim.Region.Environment.Scenes if (m_capsHandlers.ContainsKey(agentID)) { + m_capsHandlers[agentID].DeregisterHandlers(); m_capsHandlers.Remove(agentID); } }