aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authordiva2008-12-31 21:14:31 +0000
committerdiva2008-12-31 21:14:31 +0000
commit59cddd0844fa6fcdf33cf6c4960f5b60d40174d0 (patch)
tree56ec8c2274ef4766f92e67c637a072c73d0f1569
parentMinor bug fix in HG home regions management, removing the use of m_knownRegio... (diff)
downloadopensim-SC_OLD-59cddd0844fa6fcdf33cf6c4960f5b60d40174d0.zip
opensim-SC_OLD-59cddd0844fa6fcdf33cf6c4960f5b60d40174d0.tar.gz
opensim-SC_OLD-59cddd0844fa6fcdf33cf6c4960f5b60d40174d0.tar.bz2
opensim-SC_OLD-59cddd0844fa6fcdf33cf6c4960f5b60d40174d0.tar.xz
Beginning of true REST style for interregion comms, SendChildAgentUpdate only. Agents are now resources accessed at http://<host>:<port>/agent/<uuid>/[action/]. PUT is SendChildAgentUpdate.
-rw-r--r--OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs99
1 files changed, 92 insertions, 7 deletions
diff --git a/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs b/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs
index 255c185..b7c9269 100644
--- a/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs
+++ b/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs
@@ -41,6 +41,7 @@ using Nwc.XmlRpc;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Framework.Communications; 42using OpenSim.Framework.Communications;
43using OpenSim.Framework.Communications.Cache; 43using OpenSim.Framework.Communications.Cache;
44using OpenSim.Framework.Servers;
44using OpenSim.Region.Environment.Interfaces; 45using OpenSim.Region.Environment.Interfaces;
45using OpenSim.Region.Interfaces; 46using OpenSim.Region.Interfaces;
46using OpenSim.Region.Environment.Scenes; 47using OpenSim.Region.Environment.Scenes;
@@ -120,7 +121,7 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
120 121
121 protected virtual void AddHTTPHandlers() 122 protected virtual void AddHTTPHandlers()
122 { 123 {
123 m_aScene.AddHTTPHandler("/ChildAgentUpdate/", ChildAgentUpdateHandler); 124 m_aScene.AddHTTPHandler("/agent/", AgentHandler);
124 } 125 }
125 126
126 #endregion /* IRegionModule */ 127 #endregion /* IRegionModule */
@@ -139,14 +140,16 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
139 { 140 {
140 return DoChildAgentUpdateCall(regInfo, cAgentData); 141 return DoChildAgentUpdateCall(regInfo, cAgentData);
141 } 142 }
142 143 //else
144 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
143 return false; 145 return false;
144 146
145 } 147 }
146 148
147 protected bool DoChildAgentUpdateCall(RegionInfo region, AgentData cAgentData) 149 protected bool DoChildAgentUpdateCall(RegionInfo region, AgentData cAgentData)
148 { 150 {
149 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/ChildAgentUpdate/"; 151 // Eventually, we want to use a caps url instead of the agentID
152 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/";
150 //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); 153 //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri);
151 154
152 WebRequest ChildUpdateRequest = WebRequest.Create(uri); 155 WebRequest ChildUpdateRequest = WebRequest.Create(uri);
@@ -232,13 +235,66 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
232 235
233 #region Called from remote instances on this instance 236 #region Called from remote instances on this instance
234 237
235 public Hashtable ChildAgentUpdateHandler(Hashtable request) 238 public Hashtable AgentHandler(Hashtable request)
236 { 239 {
237 //m_log.Debug("[CONNECTION DEBUGGING]: ChildDataUpdateHandler Called"); 240 //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called");
241
242 //Console.WriteLine("---------------------------");
243 //Console.WriteLine(" >> uri=" + request["uri"]);
244 //Console.WriteLine(" >> content-type=" + request["content-type"]);
245 //Console.WriteLine(" >> http-method=" + request["http-method"]);
246 //Console.WriteLine("---------------------------\n");
238 247
239 Hashtable responsedata = new Hashtable(); 248 Hashtable responsedata = new Hashtable();
240 responsedata["content_type"] = "text/html"; 249 responsedata["content_type"] = "text/html";
241 250
251 UUID agentID;
252 string action;
253 if (!GetParams((string)request["uri"], out agentID, out action))
254 {
255 m_log.InfoFormat("[REST COMMS]: Invalid parameters for agent message {0}", request["uri"]);
256 responsedata["int_response_code"] = 404;
257 responsedata["str_response_string"] = "false";
258
259 return responsedata;
260 }
261
262 // Next, let's parse the verb
263 string method = (string)request["http-method"];
264 if (method.Equals("PUT"))
265 {
266 DoPut(request, responsedata);
267 return responsedata;
268 }
269 else if (method.Equals("POST"))
270 {
271 m_log.InfoFormat("[REST COMMS]: method {0} not implemented yet in agent message", method);
272 responsedata["int_response_code"] = 404;
273 responsedata["str_response_string"] = "false";
274
275 return responsedata;
276 }
277 else if (method.Equals("GET"))
278 {
279 m_log.InfoFormat("[REST COMMS]: method {0} not implemented yet in agent message", method);
280 responsedata["int_response_code"] = 404;
281 responsedata["str_response_string"] = "false";
282
283 return responsedata;
284 }
285 else
286 {
287 m_log.InfoFormat("[REST COMMS]: method {0} not supported in agent message", method);
288 responsedata["int_response_code"] = 404;
289 responsedata["str_response_string"] = "false";
290
291 return responsedata;
292 }
293
294 }
295
296 protected virtual void DoPut(Hashtable request, Hashtable responsedata)
297 {
242 OSDMap args = null; 298 OSDMap args = null;
243 try 299 try
244 { 300 {
@@ -259,7 +315,7 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
259 responsedata["int_response_code"] = 400; 315 responsedata["int_response_code"] = 400;
260 responsedata["str_response_string"] = "false"; 316 responsedata["str_response_string"] = "false";
261 317
262 return responsedata; 318 return ;
263 } 319 }
264 320
265 // retrieve the regionhandle 321 // retrieve the regionhandle
@@ -275,20 +331,49 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
275 catch (Exception ex) 331 catch (Exception ex)
276 { 332 {
277 m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); 333 m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
334 return;
278 } 335 }
279 //agent.Dump(); 336 //agent.Dump();
280 337
338 // This is the meaning of PUT agent
281 bool result = m_localBackend.SendChildAgentUpdate(regionhandle, agent); 339 bool result = m_localBackend.SendChildAgentUpdate(regionhandle, agent);
282 340
283 341
284 responsedata["int_response_code"] = 200; 342 responsedata["int_response_code"] = 200;
285 responsedata["str_response_string"] = result.ToString(); 343 responsedata["str_response_string"] = result.ToString();
286 return responsedata;
287 } 344 }
288 345
289 #endregion 346 #endregion
290 347
291 #region Misc 348 #region Misc
349 /// <summary>
350 /// Extract the param from an uri.
351 /// </summary>
352 /// <param name="uri">Something like this: /agent/uuid/ or /agent/uuid/release</param>
353 /// <param name="uri">uuid on uuid field</param>
354 /// <param name="action">optional action</param>
355 protected bool GetParams(string uri, out UUID uuid, out string action)
356 {
357 uuid = UUID.Zero;
358 action = "";
359
360 uri = uri.Trim(new char[] { '/' });
361 string[] parts = uri.Split('/');
362 if (parts.Length <= 1)
363 {
364 return false;
365 }
366 else
367 {
368 if (!UUID.TryParse(parts[1], out uuid))
369 return false;
370
371 if (parts.Length >= 3)
372 action = parts[2];
373
374 return true;
375 }
376 }
292 377
293 protected virtual ulong GetRegionHandle(RegionInfo region) 378 protected virtual ulong GetRegionHandle(RegionInfo region)
294 { 379 {