aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs64
1 files changed, 35 insertions, 29 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index a1d9167..6c69fec 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -283,46 +283,52 @@ namespace OpenSim.Services.Connectors.Hypergrid
283 283
284 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason) 284 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
285 { 285 {
286 HttpWebRequest AgentCreateRequest = null; 286 m_log.WarnFormat("[GATEKEEPER SERVICE CONNECTOR]: CreateAgent start");
287
287 myipaddress = String.Empty; 288 myipaddress = String.Empty;
288 reason = String.Empty; 289 reason = String.Empty;
289 290
290 if (SendRequest(destination, aCircuit, flags, out reason, out AgentCreateRequest)) 291 if (destination == null)
291 { 292 {
292 string response = GetResponse(AgentCreateRequest, out reason); 293 m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Given destination is null");
293 bool success = true; 294 return false;
294 UnpackResponse(response, out success, out reason, out myipaddress);
295 return success;
296 } 295 }
297 296
298 return false; 297 string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/";
299 }
300
301 protected void UnpackResponse(string response, out bool result, out string reason, out string ipaddress)
302 {
303 result = true;
304 reason = string.Empty;
305 ipaddress = string.Empty;
306 298
307 if (!String.IsNullOrEmpty(response)) 299 try
308 { 300 {
309 try 301 OSDMap args = aCircuit.PackAgentCircuitData();
310 { 302
311 // we assume we got an OSDMap back 303 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
312 OSDMap r = Util.GetOSDMap(response); 304 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
313 result = r["success"].AsBoolean(); 305 args["destination_name"] = OSD.FromString(destination.RegionName);
314 reason = r["reason"].AsString(); 306 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
315 ipaddress = r["your_ip"].AsString(); 307 args["teleport_flags"] = OSD.FromString(flags.ToString());
316 } 308
317 catch (NullReferenceException e) 309 OSDMap result = WebUtil.PostToService(uri,args);
310 if (result["Success"].AsBoolean())
318 { 311 {
319 m_log.InfoFormat("[GATEKEEPER SERVICE CONNECTOR]: exception on UnpackResponse of DoCreateChildAgentCall {0}", e.Message); 312 OSDMap unpacked = (OSDMap)result["_Result"];
320 reason = "Internal error"; 313
321 result = false; 314 if (unpacked != null)
315 {
316 reason = unpacked["reason"].AsString();
317 myipaddress = unpacked["your_ip"].AsString();
318 return unpacked["success"].AsBoolean();
319 }
322 } 320 }
321
322 reason = result["Message"] != null ? result["Message"].AsString() : "error";
323 return false;
324 }
325 catch (Exception e)
326 {
327 m_log.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e.ToString());
328 reason = e.Message;
323 } 329 }
324 }
325
326 330
331 return false;
332 }
327 } 333 }
328} 334}