aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server/Handlers/Simulation/AgentHandlers.cs')
-rw-r--r--OpenSim/Server/Handlers/Simulation/AgentHandlers.cs105
1 files changed, 17 insertions, 88 deletions
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
index c62f256..964ccf8 100644
--- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
@@ -27,11 +27,13 @@
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Specialized;
30using System.IO; 31using System.IO;
31using System.IO.Compression; 32using System.IO.Compression;
32using System.Reflection; 33using System.Reflection;
33using System.Net; 34using System.Net;
34using System.Text; 35using System.Text;
36using System.Web;
35 37
36using OpenSim.Server.Base; 38using OpenSim.Server.Base;
37using OpenSim.Server.Handlers.Base; 39using OpenSim.Server.Handlers.Base;
@@ -90,19 +92,13 @@ namespace OpenSim.Server.Handlers.Simulation
90 92
91 // Next, let's parse the verb 93 // Next, let's parse the verb
92 string method = (string)request["http-method"]; 94 string method = (string)request["http-method"];
93 if (method.Equals("GET")) 95 if (method.Equals("DELETE"))
94 { 96 {
95 DoAgentGet(request, responsedata, agentID, regionID); 97 string auth_token = string.Empty;
96 return responsedata; 98 if (request.ContainsKey("auth"))
97 } 99 auth_token = request["auth"].ToString();
98 else if (method.Equals("DELETE")) 100
99 { 101 DoAgentDelete(request, responsedata, agentID, action, regionID, auth_token);
100 DoAgentDelete(request, responsedata, agentID, action, regionID);
101 return responsedata;
102 }
103 else if (method.Equals("DELETECHILD"))
104 {
105 DoChildAgentDelete(request, responsedata, agentID, action, regionID);
106 return responsedata; 102 return responsedata;
107 } 103 }
108 else if (method.Equals("QUERYACCESS")) 104 else if (method.Equals("QUERYACCESS"))
@@ -112,7 +108,7 @@ namespace OpenSim.Server.Handlers.Simulation
112 } 108 }
113 else 109 else
114 { 110 {
115 m_log.InfoFormat("[AGENT HANDLER]: method {0} not supported in agent message", method); 111 m_log.ErrorFormat("[AGENT HANDLER]: method {0} not supported in agent message {1} (caller is {2})", method, (string)request["uri"], Util.GetCallerIP(request));
116 responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed; 112 responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed;
117 responsedata["str_response_string"] = "Method not allowed"; 113 responsedata["str_response_string"] = "Method not allowed";
118 114
@@ -161,79 +157,12 @@ namespace OpenSim.Server.Handlers.Simulation
161// Console.WriteLine("str_response_string [{0}]", responsedata["str_response_string"]); 157// Console.WriteLine("str_response_string [{0}]", responsedata["str_response_string"]);
162 } 158 }
163 159
164 protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, UUID regionID) 160 protected void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID, string auth_token)
165 {
166 if (m_SimulationService == null)
167 {
168 m_log.Debug("[AGENT HANDLER]: Agent GET called. Harmless but useless.");
169 responsedata["content_type"] = "application/json";
170 responsedata["int_response_code"] = HttpStatusCode.NotImplemented;
171 responsedata["str_response_string"] = string.Empty;
172
173 return;
174 }
175
176 GridRegion destination = new GridRegion();
177 destination.RegionID = regionID;
178
179 IAgentData agent = null;
180 bool result = m_SimulationService.RetrieveAgent(destination, id, out agent);
181 OSDMap map = null;
182 if (result)
183 {
184 if (agent != null) // just to make sure
185 {
186 map = agent.Pack();
187 string strBuffer = "";
188 try
189 {
190 strBuffer = OSDParser.SerializeJsonString(map);
191 }
192 catch (Exception e)
193 {
194 m_log.WarnFormat("[AGENT HANDLER]: Exception thrown on serialization of DoAgentGet: {0}", e.Message);
195 responsedata["int_response_code"] = HttpStatusCode.InternalServerError;
196 // ignore. buffer will be empty, caller should check.
197 }
198
199 responsedata["content_type"] = "application/json";
200 responsedata["int_response_code"] = HttpStatusCode.OK;
201 responsedata["str_response_string"] = strBuffer;
202 }
203 else
204 {
205 responsedata["int_response_code"] = HttpStatusCode.InternalServerError;
206 responsedata["str_response_string"] = "Internal error";
207 }
208 }
209 else
210 {
211 responsedata["int_response_code"] = HttpStatusCode.NotFound;
212 responsedata["str_response_string"] = "Not Found";
213 }
214 }
215
216 protected void DoChildAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID)
217 { 161 {
218 m_log.Debug(" >>> DoChildAgentDelete action:" + action + "; RegionID:" + regionID); 162 if (string.IsNullOrEmpty(action))
219 163 m_log.DebugFormat("[AGENT HANDLER]: >>> DELETE <<< RegionID: {0}; from: {1}; auth_code: {2}", regionID, Util.GetCallerIP(request), auth_token);
220 GridRegion destination = new GridRegion();
221 destination.RegionID = regionID;
222
223 if (action.Equals("release"))
224 ReleaseAgent(regionID, id);
225 else 164 else
226 m_SimulationService.CloseChildAgent(destination, id); 165 m_log.DebugFormat("[AGENT HANDLER]: Release {0} to RegionID: {1}", id, regionID);
227
228 responsedata["int_response_code"] = HttpStatusCode.OK;
229 responsedata["str_response_string"] = "OpenSim agent " + id.ToString();
230
231 m_log.Debug("[AGENT HANDLER]: Child Agent Released/Deleted.");
232 }
233
234 protected void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID)
235 {
236 m_log.Debug(" >>> DoDelete action:" + action + "; RegionID:" + regionID);
237 166
238 GridRegion destination = new GridRegion(); 167 GridRegion destination = new GridRegion();
239 destination.RegionID = regionID; 168 destination.RegionID = regionID;
@@ -241,12 +170,12 @@ namespace OpenSim.Server.Handlers.Simulation
241 if (action.Equals("release")) 170 if (action.Equals("release"))
242 ReleaseAgent(regionID, id); 171 ReleaseAgent(regionID, id);
243 else 172 else
244 Util.FireAndForget(delegate { m_SimulationService.CloseAgent(destination, id); }); 173 Util.FireAndForget(delegate { m_SimulationService.CloseAgent(destination, id, auth_token); });
245 174
246 responsedata["int_response_code"] = HttpStatusCode.OK; 175 responsedata["int_response_code"] = HttpStatusCode.OK;
247 responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); 176 responsedata["str_response_string"] = "OpenSim agent " + id.ToString();
248 177
249 m_log.DebugFormat("[AGENT HANDLER]: Agent {0} Released/Deleted from region {1}", id, regionID); 178 //m_log.DebugFormat("[AGENT HANDLER]: Agent {0} Released/Deleted from region {1}", id, regionID);
250 } 179 }
251 180
252 protected virtual void ReleaseAgent(UUID regionID, UUID id) 181 protected virtual void ReleaseAgent(UUID regionID, UUID id)
@@ -274,7 +203,7 @@ namespace OpenSim.Server.Handlers.Simulation
274 m_SimulationService = null; 203 m_SimulationService = null;
275 } 204 }
276 205
277 public override byte[] Handle(string path, Stream request, 206 protected override byte[] ProcessRequest(string path, Stream request,
278 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 207 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
279 { 208 {
280// m_log.DebugFormat("[SIMULATION]: Stream handler called"); 209// m_log.DebugFormat("[SIMULATION]: Stream handler called");
@@ -488,7 +417,7 @@ namespace OpenSim.Server.Handlers.Simulation
488 m_SimulationService = null; 417 m_SimulationService = null;
489 } 418 }
490 419
491 public override byte[] Handle(string path, Stream request, 420 protected override byte[] ProcessRequest(string path, Stream request,
492 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 421 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
493 { 422 {
494// m_log.DebugFormat("[SIMULATION]: Stream handler called"); 423// m_log.DebugFormat("[SIMULATION]: Stream handler called");