diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps')
5 files changed, 296 insertions, 51 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 185f9ce..88c4d7f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -96,7 +96,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
96 | // private static readonly string m_fetchInventoryPath = "0006/"; | 96 | // private static readonly string m_fetchInventoryPath = "0006/"; |
97 | private static readonly string m_copyFromNotecardPath = "0007/"; | 97 | private static readonly string m_copyFromNotecardPath = "0007/"; |
98 | // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. | 98 | // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. |
99 | 99 | private static readonly string m_getObjectPhysicsDataPath = "0101/"; | |
100 | private static readonly string m_getObjectCostPath = "0102/"; | ||
101 | private static readonly string m_ResourceCostSelectedPath = "0103/"; | ||
102 | |||
100 | 103 | ||
101 | // These are callbacks which will be setup by the scene so that we can update scene data when we | 104 | // These are callbacks which will be setup by the scene so that we can update scene data when we |
102 | // receive capability calls | 105 | // receive capability calls |
@@ -204,6 +207,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
204 | m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req); | 207 | m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req); |
205 | m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); | 208 | m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); |
206 | m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); | 209 | m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); |
210 | IRequestHandler getObjectPhysicsDataHandler = new RestStreamHandler("POST", capsBase + m_getObjectPhysicsDataPath, GetObjectPhysicsData); | ||
211 | m_HostCapsObj.RegisterHandler("GetObjectPhysicsData", getObjectPhysicsDataHandler); | ||
212 | IRequestHandler getObjectCostHandler = new RestStreamHandler("POST", capsBase + m_getObjectCostPath, GetObjectCost); | ||
213 | m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler); | ||
214 | IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected); | ||
215 | m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler); | ||
216 | |||
217 | |||
207 | 218 | ||
208 | m_HostCapsObj.RegisterHandler( | 219 | m_HostCapsObj.RegisterHandler( |
209 | "CopyInventoryFromNotecard", | 220 | "CopyInventoryFromNotecard", |
@@ -854,6 +865,151 @@ namespace OpenSim.Region.ClientStack.Linden | |||
854 | response["int_response_code"] = 200; | 865 | response["int_response_code"] = 200; |
855 | return LLSDHelpers.SerialiseLLSDReply(response); | 866 | return LLSDHelpers.SerialiseLLSDReply(response); |
856 | } | 867 | } |
868 | |||
869 | public string GetObjectPhysicsData(string request, string path, | ||
870 | string param, IOSHttpRequest httpRequest, | ||
871 | IOSHttpResponse httpResponse) | ||
872 | { | ||
873 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | ||
874 | OSDMap resp = new OSDMap(); | ||
875 | OSDArray object_ids = (OSDArray)req["object_ids"]; | ||
876 | |||
877 | for (int i = 0 ; i < object_ids.Count ; i++) | ||
878 | { | ||
879 | UUID uuid = object_ids[i].AsUUID(); | ||
880 | |||
881 | SceneObjectPart obj = m_Scene.GetSceneObjectPart(uuid); | ||
882 | if (obj != null) | ||
883 | { | ||
884 | OSDMap object_data = new OSDMap(); | ||
885 | |||
886 | object_data["PhysicsShapeType"] = obj.PhysicsShapeType; | ||
887 | object_data["Density"] = obj.Density; | ||
888 | object_data["Friction"] = obj.Friction; | ||
889 | object_data["Restitution"] = obj.Bounciness; | ||
890 | object_data["GravityMultiplier"] = obj.GravityModifier; | ||
891 | |||
892 | resp[uuid.ToString()] = object_data; | ||
893 | } | ||
894 | } | ||
895 | |||
896 | string response = OSDParser.SerializeLLSDXmlString(resp); | ||
897 | return response; | ||
898 | } | ||
899 | |||
900 | public string GetObjectCost(string request, string path, | ||
901 | string param, IOSHttpRequest httpRequest, | ||
902 | IOSHttpResponse httpResponse) | ||
903 | { | ||
904 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | ||
905 | OSDMap resp = new OSDMap(); | ||
906 | |||
907 | OSDArray object_ids = (OSDArray)req["object_ids"]; | ||
908 | |||
909 | for (int i = 0; i < object_ids.Count; i++) | ||
910 | { | ||
911 | UUID uuid = object_ids[i].AsUUID(); | ||
912 | |||
913 | SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid); | ||
914 | |||
915 | if (part != null) | ||
916 | { | ||
917 | SceneObjectGroup grp = part.ParentGroup; | ||
918 | if (grp != null) | ||
919 | { | ||
920 | float linksetCost; | ||
921 | float linksetPhysCost; | ||
922 | float partCost; | ||
923 | float partPhysCost; | ||
924 | |||
925 | grp.GetResourcesCosts(part, out linksetCost, out linksetPhysCost, out partCost, out partPhysCost); | ||
926 | |||
927 | OSDMap object_data = new OSDMap(); | ||
928 | object_data["linked_set_resource_cost"] = linksetCost; | ||
929 | object_data["resource_cost"] = partCost; | ||
930 | object_data["physics_cost"] = partPhysCost; | ||
931 | object_data["linked_set_physics_cost"] = linksetPhysCost; | ||
932 | |||
933 | resp[uuid.ToString()] = object_data; | ||
934 | } | ||
935 | } | ||
936 | } | ||
937 | |||
938 | string response = OSDParser.SerializeLLSDXmlString(resp); | ||
939 | return response; | ||
940 | } | ||
941 | |||
942 | public string ResourceCostSelected(string request, string path, | ||
943 | string param, IOSHttpRequest httpRequest, | ||
944 | IOSHttpResponse httpResponse) | ||
945 | { | ||
946 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | ||
947 | OSDMap resp = new OSDMap(); | ||
948 | |||
949 | |||
950 | float phys=0; | ||
951 | float stream=0; | ||
952 | float simul=0; | ||
953 | |||
954 | if (req.ContainsKey("selected_roots")) | ||
955 | { | ||
956 | OSDArray object_ids = (OSDArray)req["selected_roots"]; | ||
957 | |||
958 | // should go by SOG suming costs for all parts | ||
959 | // ll v3 works ok with several objects select we get the list and adds ok | ||
960 | // FS calls per object so results are wrong guess fs bug | ||
961 | for (int i = 0; i < object_ids.Count; i++) | ||
962 | { | ||
963 | UUID uuid = object_ids[i].AsUUID(); | ||
964 | float Physc; | ||
965 | float simulc; | ||
966 | float streamc; | ||
967 | |||
968 | SceneObjectGroup grp = m_Scene.GetGroupByPrim(uuid); | ||
969 | if (grp != null) | ||
970 | { | ||
971 | grp.GetSelectedCosts(out Physc, out streamc, out simulc); | ||
972 | phys += Physc; | ||
973 | stream += streamc; | ||
974 | simul += simulc; | ||
975 | } | ||
976 | } | ||
977 | } | ||
978 | else if (req.ContainsKey("selected_prims")) | ||
979 | { | ||
980 | OSDArray object_ids = (OSDArray)req["selected_prims"]; | ||
981 | |||
982 | // don't see in use in any of the 2 viewers | ||
983 | // guess it should be for edit linked but... nothing | ||
984 | // should go to SOP per part | ||
985 | for (int i = 0; i < object_ids.Count; i++) | ||
986 | { | ||
987 | UUID uuid = object_ids[i].AsUUID(); | ||
988 | |||
989 | SceneObjectPart part = m_Scene.GetSceneObjectPart(uuid); | ||
990 | if (part != null) | ||
991 | { | ||
992 | phys += part.PhysicsCost; | ||
993 | stream += part.StreamingCost; | ||
994 | simul += part.SimulationCost; | ||
995 | } | ||
996 | } | ||
997 | } | ||
998 | |||
999 | if (simul != 0) | ||
1000 | { | ||
1001 | OSDMap object_data = new OSDMap(); | ||
1002 | |||
1003 | object_data["physics"] = phys; | ||
1004 | object_data["streaming"] = stream; | ||
1005 | object_data["simulation"] = simul; | ||
1006 | |||
1007 | resp["selected"] = object_data; | ||
1008 | } | ||
1009 | |||
1010 | string response = OSDParser.SerializeLLSDXmlString(resp); | ||
1011 | return response; | ||
1012 | } | ||
857 | } | 1013 | } |
858 | 1014 | ||
859 | public class AssetUploader | 1015 | public class AssetUploader |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 594b229..ebfe687 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -377,7 +377,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
377 | // TODO: Add EventQueueGet name/description for diagnostics | 377 | // TODO: Add EventQueueGet name/description for diagnostics |
378 | MainServer.Instance.AddPollServiceHTTPHandler( | 378 | MainServer.Instance.AddPollServiceHTTPHandler( |
379 | eventQueueGetPath, | 379 | eventQueueGetPath, |
380 | new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); | 380 | new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID, 1000)); |
381 | 381 | ||
382 | // m_log.DebugFormat( | 382 | // m_log.DebugFormat( |
383 | // "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", | 383 | // "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", |
@@ -831,5 +831,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
831 | { | 831 | { |
832 | return EventQueueHelper.BuildEvent(eventName, eventBody); | 832 | return EventQueueHelper.BuildEvent(eventName, eventBody); |
833 | } | 833 | } |
834 | |||
835 | public void partPhysicsProperties(uint localID, byte physhapetype, | ||
836 | float density, float friction, float bounce, float gravmod,UUID avatarID) | ||
837 | { | ||
838 | OSD item = EventQueueHelper.partPhysicsProperties(localID, physhapetype, | ||
839 | density, friction, bounce, gravmod); | ||
840 | Enqueue(item, avatarID); | ||
841 | } | ||
834 | } | 842 | } |
835 | } | 843 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index 3f49aba..b9222e3 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs | |||
@@ -395,5 +395,25 @@ namespace OpenSim.Region.ClientStack.Linden | |||
395 | return message; | 395 | return message; |
396 | } | 396 | } |
397 | 397 | ||
398 | public static OSD partPhysicsProperties(uint localID, byte physhapetype, | ||
399 | float density, float friction, float bounce, float gravmod) | ||
400 | { | ||
401 | |||
402 | OSDMap physinfo = new OSDMap(6); | ||
403 | physinfo["LocalID"] = localID; | ||
404 | physinfo["Density"] = density; | ||
405 | physinfo["Friction"] = friction; | ||
406 | physinfo["GravityMultiplier"] = gravmod; | ||
407 | physinfo["Restitution"] = bounce; | ||
408 | physinfo["PhysicsShapeType"] = (int)physhapetype; | ||
409 | |||
410 | OSDArray array = new OSDArray(1); | ||
411 | array.Add(physinfo); | ||
412 | |||
413 | OSDMap llsdBody = new OSDMap(1); | ||
414 | llsdBody.Add("ObjectData", array); | ||
415 | |||
416 | return BuildEvent("ObjectPhysicsProperties", llsdBody); | ||
417 | } | ||
398 | } | 418 | } |
399 | } | 419 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs index 36af55f..413536d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs | |||
@@ -64,6 +64,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
64 | private Commands m_commands = new Commands(); | 64 | private Commands m_commands = new Commands(); |
65 | public ICommands Commands { get { return m_commands; } } | 65 | public ICommands Commands { get { return m_commands; } } |
66 | 66 | ||
67 | public event ConsoleMessage OnConsoleMessage; | ||
68 | |||
67 | public void Initialise(IConfigSource source) | 69 | public void Initialise(IConfigSource source) |
68 | { | 70 | { |
69 | m_commands.AddCommand( "Help", false, "help", "help [<item>]", "Display help on a particular command or on a list of commands in a category", Help); | 71 | m_commands.AddCommand( "Help", false, "help", "help [<item>]", "Display help on a particular command or on a list of commands in a category", Help); |
@@ -118,6 +120,11 @@ namespace OpenSim.Region.ClientStack.Linden | |||
118 | OSD osd = OSD.FromString(message); | 120 | OSD osd = OSD.FromString(message); |
119 | 121 | ||
120 | m_eventQueue.Enqueue(EventQueueHelper.BuildEvent("SimConsoleResponse", osd), agentID); | 122 | m_eventQueue.Enqueue(EventQueueHelper.BuildEvent("SimConsoleResponse", osd), agentID); |
123 | |||
124 | ConsoleMessage handlerConsoleMessage = OnConsoleMessage; | ||
125 | |||
126 | if (handlerConsoleMessage != null) | ||
127 | handlerConsoleMessage( agentID, message); | ||
121 | } | 128 | } |
122 | 129 | ||
123 | public bool RunCommand(string command, UUID invokerID) | 130 | public bool RunCommand(string command, UUID invokerID) |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 2359bd6..b77ead3 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | |||
@@ -27,12 +27,15 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Threading; | ||
31 | using log4net; | 33 | using log4net; |
32 | using Nini.Config; | 34 | using Nini.Config; |
33 | using Mono.Addins; | 35 | using Mono.Addins; |
34 | using OpenMetaverse; | 36 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Servers; | ||
36 | using OpenSim.Framework.Servers.HttpServer; | 39 | using OpenSim.Framework.Servers.HttpServer; |
37 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
@@ -48,67 +51,49 @@ namespace OpenSim.Region.ClientStack.Linden | |||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 51 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] |
49 | public class WebFetchInvDescModule : INonSharedRegionModule | 52 | public class WebFetchInvDescModule : INonSharedRegionModule |
50 | { | 53 | { |
51 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 55 | ||
53 | private Scene m_scene; | 56 | private Scene m_scene; |
54 | 57 | ||
55 | private IInventoryService m_InventoryService; | 58 | private IInventoryService m_InventoryService; |
56 | private ILibraryService m_LibraryService; | 59 | private ILibraryService m_LibraryService; |
57 | 60 | ||
58 | private bool m_Enabled; | 61 | private WebFetchInvDescHandler m_webFetchHandler; |
59 | 62 | ||
60 | private string m_fetchInventoryDescendents2Url; | 63 | private ManualResetEvent m_ev = new ManualResetEvent(true); |
61 | private string m_webFetchInventoryDescendentsUrl; | 64 | private object m_lock = new object(); |
62 | 65 | ||
63 | private WebFetchInvDescHandler m_webFetchHandler; | 66 | private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); |
67 | private Dictionary<UUID, Hashtable> m_requests = new Dictionary<UUID, Hashtable>(); | ||
64 | 68 | ||
65 | #region ISharedRegionModule Members | 69 | #region ISharedRegionModule Members |
66 | 70 | ||
67 | public void Initialise(IConfigSource source) | 71 | public void Initialise(IConfigSource source) |
68 | { | 72 | { |
69 | IConfig config = source.Configs["ClientStack.LindenCaps"]; | ||
70 | if (config == null) | ||
71 | return; | ||
72 | |||
73 | m_fetchInventoryDescendents2Url = config.GetString("Cap_FetchInventoryDescendents2", string.Empty); | ||
74 | m_webFetchInventoryDescendentsUrl = config.GetString("Cap_WebFetchInventoryDescendents", string.Empty); | ||
75 | |||
76 | if (m_fetchInventoryDescendents2Url != string.Empty || m_webFetchInventoryDescendentsUrl != string.Empty) | ||
77 | { | ||
78 | m_Enabled = true; | ||
79 | } | ||
80 | } | 73 | } |
81 | 74 | ||
82 | public void AddRegion(Scene s) | 75 | public void AddRegion(Scene s) |
83 | { | 76 | { |
84 | if (!m_Enabled) | ||
85 | return; | ||
86 | |||
87 | m_scene = s; | 77 | m_scene = s; |
88 | } | 78 | } |
89 | 79 | ||
90 | public void RemoveRegion(Scene s) | 80 | public void RemoveRegion(Scene s) |
91 | { | 81 | { |
92 | if (!m_Enabled) | ||
93 | return; | ||
94 | |||
95 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | 82 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; |
83 | m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps; | ||
96 | m_scene = null; | 84 | m_scene = null; |
97 | } | 85 | } |
98 | 86 | ||
99 | public void RegionLoaded(Scene s) | 87 | public void RegionLoaded(Scene s) |
100 | { | 88 | { |
101 | if (!m_Enabled) | ||
102 | return; | ||
103 | |||
104 | m_InventoryService = m_scene.InventoryService; | 89 | m_InventoryService = m_scene.InventoryService; |
105 | m_LibraryService = m_scene.LibraryService; | 90 | m_LibraryService = m_scene.LibraryService; |
106 | 91 | ||
107 | // We'll reuse the same handler for all requests. | 92 | // We'll reuse the same handler for all requests. |
108 | if (m_fetchInventoryDescendents2Url == "localhost" || m_webFetchInventoryDescendentsUrl == "localhost") | 93 | m_webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService); |
109 | m_webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService); | ||
110 | 94 | ||
111 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | 95 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; |
96 | m_scene.EventManager.OnDeregisterCaps += DeregisterCaps; | ||
112 | } | 97 | } |
113 | 98 | ||
114 | public void PostInitialise() | 99 | public void PostInitialise() |
@@ -128,41 +113,110 @@ namespace OpenSim.Region.ClientStack.Linden | |||
128 | 113 | ||
129 | private void RegisterCaps(UUID agentID, Caps caps) | 114 | private void RegisterCaps(UUID agentID, Caps caps) |
130 | { | 115 | { |
131 | if (m_webFetchInventoryDescendentsUrl != "") | 116 | string capUrl = "/CAPS/" + UUID.Random() + "/"; |
132 | RegisterFetchCap(agentID, caps, "WebFetchInventoryDescendents", m_webFetchInventoryDescendentsUrl); | 117 | |
118 | // Register this as a poll service | ||
119 | PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, agentID, 300000); | ||
120 | args.Type = PollServiceEventArgs.EventType.Inventory; | ||
121 | MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); | ||
122 | |||
123 | string hostName = m_scene.RegionInfo.ExternalHostName; | ||
124 | uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; | ||
125 | string protocol = "http"; | ||
126 | |||
127 | if (MainServer.Instance.UseSSL) | ||
128 | { | ||
129 | hostName = MainServer.Instance.SSLCommonName; | ||
130 | port = MainServer.Instance.SSLPort; | ||
131 | protocol = "https"; | ||
132 | } | ||
133 | caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); | ||
133 | 134 | ||
134 | if (m_fetchInventoryDescendents2Url != "") | 135 | m_capsDict[agentID] = capUrl; |
135 | RegisterFetchCap(agentID, caps, "FetchInventoryDescendents2", m_fetchInventoryDescendents2Url); | ||
136 | } | 136 | } |
137 | 137 | ||
138 | private void RegisterFetchCap(UUID agentID, Caps caps, string capName, string url) | 138 | private void DeregisterCaps(UUID agentID, Caps caps) |
139 | { | 139 | { |
140 | string capUrl; | 140 | string capUrl; |
141 | 141 | ||
142 | if (url == "localhost") | 142 | if (m_capsDict.TryGetValue(agentID, out capUrl)) |
143 | { | 143 | { |
144 | capUrl = "/CAPS/" + UUID.Random(); | 144 | MainServer.Instance.RemoveHTTPHandler("", capUrl); |
145 | m_capsDict.Remove(agentID); | ||
146 | } | ||
147 | } | ||
145 | 148 | ||
146 | IRequestHandler reqHandler | 149 | public void HttpRequestHandler(UUID requestID, Hashtable request) |
147 | = new RestStreamHandler( | 150 | { |
148 | "POST", | 151 | // m_log.DebugFormat("[FETCH2]: Received request {0}", requestID); |
149 | capUrl, | 152 | m_requests[requestID] = request; |
150 | m_webFetchHandler.FetchInventoryDescendentsRequest, | 153 | } |
151 | "FetchInventoryDescendents2", | ||
152 | agentID.ToString()); | ||
153 | 154 | ||
154 | caps.RegisterHandler(capName, reqHandler); | 155 | private bool HasEvents(UUID requestID, UUID sessionID) |
156 | { | ||
157 | lock (m_lock) | ||
158 | { | ||
159 | if (m_ev.WaitOne(0)) | ||
160 | { | ||
161 | m_ev.Reset(); | ||
162 | return true; | ||
163 | } | ||
164 | return false; | ||
155 | } | 165 | } |
156 | else | 166 | } |
167 | |||
168 | private Hashtable NoEvents(UUID requestID, UUID sessionID) | ||
169 | { | ||
170 | m_requests.Remove(requestID); | ||
171 | |||
172 | Hashtable response = new Hashtable(); | ||
173 | |||
174 | response["int_response_code"] = 500; | ||
175 | response["str_response_string"] = "Script timeout"; | ||
176 | response["content_type"] = "text/plain"; | ||
177 | response["keepalive"] = false; | ||
178 | response["reusecontext"] = false; | ||
179 | |||
180 | return response; | ||
181 | } | ||
182 | |||
183 | private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) | ||
184 | { | ||
185 | Hashtable response = new Hashtable(); | ||
186 | |||
187 | response["int_response_code"] = 500; | ||
188 | response["str_response_string"] = "Internal error"; | ||
189 | response["content_type"] = "text/plain"; | ||
190 | response["keepalive"] = false; | ||
191 | response["reusecontext"] = false; | ||
192 | |||
193 | try | ||
157 | { | 194 | { |
158 | capUrl = url; | 195 | Hashtable requestHash; |
196 | if (!m_requests.TryGetValue(requestID, out requestHash)) | ||
197 | { | ||
198 | lock (m_lock) | ||
199 | m_ev.Set(); | ||
200 | response["str_response_string"] = "Invalid request"; | ||
201 | return response; | ||
202 | } | ||
203 | |||
204 | // m_log.DebugFormat("[FETCH2]: Processed request {0}", requestID); | ||
159 | 205 | ||
160 | caps.RegisterHandler(capName, capUrl); | 206 | string reply = m_webFetchHandler.FetchInventoryDescendentsRequest(requestHash["body"].ToString(), String.Empty, String.Empty, null, null); |
207 | |||
208 | m_requests.Remove(requestID); | ||
209 | |||
210 | response["int_response_code"] = 200; | ||
211 | response["str_response_string"] = reply; | ||
212 | } | ||
213 | finally | ||
214 | { | ||
215 | lock (m_lock) | ||
216 | m_ev.Set(); | ||
161 | } | 217 | } |
162 | 218 | ||
163 | // m_log.DebugFormat( | 219 | return response; |
164 | // "[WEB FETCH INV DESC MODULE]: Registered capability {0} at {1} in region {2} for {3}", | ||
165 | // capName, capUrl, m_scene.RegionInfo.RegionName, agentID); | ||
166 | } | 220 | } |
167 | } | 221 | } |
168 | } \ No newline at end of file | 222 | } |