public void TestAgentCircuitDataOSDConversion() { AgentCircuitData Agent1Data = new AgentCircuitData(); Agent1Data.AgentID = AgentId; Agent1Data.Appearance = AvAppearance; Agent1Data.BaseFolder = BaseFolder; Agent1Data.CapsPath = CapsPath; Agent1Data.child = false; Agent1Data.ChildrenCapSeeds = ChildrenCapsPaths; Agent1Data.circuitcode = circuitcode; Agent1Data.firstname = firstname; Agent1Data.InventoryFolder = BaseFolder; Agent1Data.lastname = lastname; Agent1Data.SecureSessionID = SecureSessionId; Agent1Data.SessionID = SessionId; Agent1Data.startpos = StartPos; EntityTransferContext ctx = new EntityTransferContext(); OSDMap map2; OSDMap map = Agent1Data.PackAgentCircuitData(ctx); try { string str = OSDParser.SerializeJsonString(map); //System.Console.WriteLine(str); map2 = (OSDMap)OSDParser.DeserializeJson(str); } catch (System.NullReferenceException) { //spurious litjson errors :P map2 = map; Assert.That(1 == 1); return; } AgentCircuitData Agent2Data = new AgentCircuitData(); Agent2Data.UnpackAgentCircuitData(map2); Assert.That((Agent1Data.AgentID == Agent2Data.AgentID)); Assert.That((Agent1Data.BaseFolder == Agent2Data.BaseFolder)); Assert.That((Agent1Data.CapsPath == Agent2Data.CapsPath)); Assert.That((Agent1Data.child == Agent2Data.child)); Assert.That((Agent1Data.ChildrenCapSeeds.Count == Agent2Data.ChildrenCapSeeds.Count)); Assert.That((Agent1Data.circuitcode == Agent2Data.circuitcode)); Assert.That((Agent1Data.firstname == Agent2Data.firstname)); Assert.That((Agent1Data.InventoryFolder == Agent2Data.InventoryFolder)); Assert.That((Agent1Data.lastname == Agent2Data.lastname)); Assert.That((Agent1Data.SecureSessionID == Agent2Data.SecureSessionID)); Assert.That((Agent1Data.SessionID == Agent2Data.SessionID)); Assert.That((Agent1Data.startpos == Agent2Data.startpos)); /* * Enable this once VisualParams go in the packing method * for (int i = 0; i < 208; i++) * Assert.That((Agent1Data.Appearance.VisualParams[i] == Agent2Data.Appearance.VisualParams[i])); */ }
protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) { m_log.InfoFormat("[AGENTPOST]; DoAgentPost for {0} ", id); OSDMap args = Utils.GetOSDMap((string)request["body"]); if (args == null) { responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } AgentDestinationData data = CreateAgentDestinationData(); UnpackData(args, data, request); GridRegion destination = new GridRegion(); destination.RegionID = data.uuid; destination.RegionLocX = data.x; destination.RegionLocY = data.y; destination.RegionName = data.name; GridRegion gatekeeper = ExtractGatekeeper(data); AgentCircuitData aCircuit = new AgentCircuitData(); try { aCircuit.UnpackAgentCircuitData(args); } catch (Exception ex) { m_log.ErrorFormat("[AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message); responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } OSDMap resp = new OSDMap(2); string reason = String.Empty; // This is the meaning of POST agent //m_regionClient.AdjustUserInformation(aCircuit); //bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); bool result = CreateAgent(gatekeeper, destination, aCircuit, data.flags, data.fromLogin, out reason); resp["reason"] = OSD.FromString(reason); resp["success"] = OSD.FromBoolean(result); // Let's also send out the IP address of the caller back to the caller (HG 1.5) resp["your_ip"] = OSD.FromString(GetCallerIP(request)); // TODO: add reason if not String.Empty? responsedata["int_response_code"] = HttpStatusCode.OK; responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); }
public void HistoricalAgentCircuitDataOSDConversion() { string oldSerialization = "{\"agent_id\":\"522675bd-8214-40c1-b3ca-9c7f7fd170be\",\"base_folder\":\"c40b5f5f-476f-496b-bd69-b5a539c434d8\",\"caps_path\":\"http://www.opensimulator.org/Caps/Foo\",\"children_seeds\":[{\"handle\":\"18446744073709551615\",\"seed\":\"http://www.opensimulator.org/Caps/Foo2\"}],\"child\":false,\"circuit_code\":\"949030\",\"first_name\":\"CoolAvatarTest\",\"last_name\":\"test\",\"inventory_folder\":\"c40b5f5f-476f-496b-bd69-b5a539c434d8\",\"secure_session_id\":\"1e608e2b-0ddb-41f6-be0f-926f61cd3e0a\",\"session_id\":\"aa06f798-9d70-4bdb-9bbf-012a02ee2baf\",\"start_pos\":\"<5, 23, 125>\"}"; AgentCircuitData Agent1Data = new AgentCircuitData(); Agent1Data.AgentID = new UUID("522675bd-8214-40c1-b3ca-9c7f7fd170be"); Agent1Data.Appearance = AvAppearance; Agent1Data.BaseFolder = new UUID("c40b5f5f-476f-496b-bd69-b5a539c434d8"); Agent1Data.CapsPath = CapsPath; Agent1Data.child = false; Agent1Data.ChildrenCapSeeds = ChildrenCapsPaths; Agent1Data.circuitcode = circuitcode; Agent1Data.firstname = firstname; Agent1Data.InventoryFolder = new UUID("c40b5f5f-476f-496b-bd69-b5a539c434d8"); Agent1Data.lastname = lastname; Agent1Data.SecureSessionID = new UUID("1e608e2b-0ddb-41f6-be0f-926f61cd3e0a"); Agent1Data.SessionID = new UUID("aa06f798-9d70-4bdb-9bbf-012a02ee2baf"); Agent1Data.startpos = StartPos; OSDMap map2; try { map2 = (OSDMap)OSDParser.DeserializeJson(oldSerialization); AgentCircuitData Agent2Data = new AgentCircuitData(); Agent2Data.UnpackAgentCircuitData(map2); Assert.That((Agent1Data.AgentID == Agent2Data.AgentID)); Assert.That((Agent1Data.BaseFolder == Agent2Data.BaseFolder)); Assert.That((Agent1Data.CapsPath == Agent2Data.CapsPath)); Assert.That((Agent1Data.child == Agent2Data.child)); Assert.That((Agent1Data.ChildrenCapSeeds.Count == Agent2Data.ChildrenCapSeeds.Count)); Assert.That((Agent1Data.circuitcode == Agent2Data.circuitcode)); Assert.That((Agent1Data.firstname == Agent2Data.firstname)); Assert.That((Agent1Data.InventoryFolder == Agent2Data.InventoryFolder)); Assert.That((Agent1Data.lastname == Agent2Data.lastname)); Assert.That((Agent1Data.SecureSessionID == Agent2Data.SecureSessionID)); Assert.That((Agent1Data.SessionID == Agent2Data.SessionID)); Assert.That((Agent1Data.startpos == Agent2Data.startpos)); } catch (LitJson.JsonException) { //intermittant litjson errors :P Assert.That(1 == 1); } /* * Enable this once VisualParams go in the packing method * for (int i=0;i<208;i++) * Assert.That((Agent1Data.Appearance.VisualParams[i] == Agent2Data.Appearance.VisualParams[i])); */ }
public void TestAgentCircuitDataOSDConversion() { AgentCircuitData Agent1Data = new AgentCircuitData(); Agent1Data.AgentID = AgentId; Agent1Data.Appearance = AvAppearance; Agent1Data.BaseFolder = BaseFolder; Agent1Data.CapsPath = CapsPath; Agent1Data.child = false; Agent1Data.ChildrenCapSeeds = ChildrenCapsPaths; Agent1Data.circuitcode = circuitcode; Agent1Data.firstname = firstname; Agent1Data.InventoryFolder = BaseFolder; Agent1Data.lastname = lastname; Agent1Data.SecureSessionID = SecureSessionId; Agent1Data.SessionID = SessionId; Agent1Data.startpos = StartPos; OSDMap map2; OSDMap map = Agent1Data.PackAgentCircuitData(); try { string str = OSDParser.SerializeJsonString(map); map2 = (OSDMap)OSDParser.DeserializeJson(str); } catch (System.NullReferenceException) { map2 = map; Assert.That(1 == 1); return; } AgentCircuitData Agent2Data = new AgentCircuitData(); Agent2Data.UnpackAgentCircuitData(map2); Assert.That((Agent1Data.AgentID == Agent2Data.AgentID)); Assert.That((Agent1Data.BaseFolder == Agent2Data.BaseFolder)); Assert.That((Agent1Data.CapsPath == Agent2Data.CapsPath)); Assert.That((Agent1Data.child == Agent2Data.child)); Assert.That((Agent1Data.ChildrenCapSeeds.Count == Agent2Data.ChildrenCapSeeds.Count)); Assert.That((Agent1Data.circuitcode == Agent2Data.circuitcode)); Assert.That((Agent1Data.firstname == Agent2Data.firstname)); Assert.That((Agent1Data.InventoryFolder == Agent2Data.InventoryFolder)); Assert.That((Agent1Data.lastname == Agent2Data.lastname)); Assert.That((Agent1Data.SecureSessionID == Agent2Data.SecureSessionID)); Assert.That((Agent1Data.SessionID == Agent2Data.SessionID)); Assert.That((Agent1Data.startpos == Agent2Data.startpos)); }
protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) { OSDMap args = RegionClient.GetOSDMap((string)request["body"]); if (args == null) { responsedata["int_response_code"] = 400; responsedata["str_response_string"] = "false"; return; } // retrieve the regionhandle ulong regionhandle = 0; bool authorize = false; if (args.ContainsKey("destination_handle")) { UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); } if (args.ContainsKey("authorize_user")) // not implemented on the sending side yet { bool.TryParse(args["authorize_user"].AsString(), out authorize); } AgentCircuitData aCircuit = new AgentCircuitData(); try { aCircuit.UnpackAgentCircuitData(args); } catch (Exception ex) { m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildCreate message {0}", ex.Message); return; } OSDMap resp = new OSDMap(2); string reason = String.Empty; // This is the meaning of POST agent bool result = m_localBackend.SendCreateChildAgent(regionhandle, aCircuit, authorize, out reason); resp["reason"] = OSD.FromString(reason); resp["success"] = OSD.FromBoolean(result); // TODO: add reason if not String.Empty? responsedata["int_response_code"] = 200; responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); }
public bool RetrieveAgent(GridRegion destination, UUID id, bool agentIsLeaving, out AgentData agent, out AgentCircuitData circuitData) { agent = null; // Try local first if (m_localBackend.RetrieveAgent(destination, id, agentIsLeaving, out agent, out circuitData)) { return(true); } // else do the remote thing if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) { // Eventually, we want to use a caps url instead of the agentID string uri = MakeUri(destination, true) + id + "/" + destination.RegionID.ToString() + "/" + agentIsLeaving.ToString() + "/"; try { string resultStr = WebUtils.GetFromService(uri); if (resultStr != "") { OSDMap result = OSDParser.DeserializeJson(resultStr) as OSDMap; if (result["Result"] == "Not Found") { return(false); } agent = new AgentData(); if (!result.ContainsKey("AgentData")) { return(false); //Disable old simulators } agent.Unpack((OSDMap)result["AgentData"]); circuitData = new AgentCircuitData(); circuitData.UnpackAgentCircuitData((OSDMap)result["CircuitData"]); return(true); } } catch (Exception e) { MainConsole.Instance.Warn("[REMOTE SIMULATION CONNECTOR]: UpdateAgent failed with exception: " + e); } return(false); } return(false); }
protected object OnGenericEvent(string FunctionName, object parameters) { if (FunctionName == "NewUserConnection") { ICapsService service = m_scene.RequestModuleInterface <ICapsService>(); if (service != null) { OSDMap param = (OSDMap)parameters; AgentCircuitData circuit = new AgentCircuitData(); circuit.UnpackAgentCircuitData((OSDMap)param["Agent"]); service.CreateCAPS(circuit.AgentID, CapsUtil.GetCapsSeedPath(circuit.CapsPath), m_scene.RegionInfo.RegionHandle, !circuit.child, circuit); IClientCapsService clientCaps = service.GetClientCapsService(circuit.AgentID); if (clientCaps != null) { IRegionClientCapsService regionCaps = clientCaps.GetCapsService(m_scene.RegionInfo.RegionHandle); if (regionCaps != null) { regionCaps.AddCAPS((OSDMap)param["CapsUrls"]); } } } } else if (FunctionName == "UserStatusChange") { UserInfo info = (UserInfo)parameters; if (!info.IsOnline) //Logging out { ICapsService service = m_scene.RequestModuleInterface <ICapsService>(); if (service != null) { service.RemoveCAPS(UUID.Parse(info.UserID)); } } } return(null); }
protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) { EntityTransferContext ctx = new EntityTransferContext(); OSDMap args = Utils.GetOSDMap((string)request["body"]); if (args == null) { responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } if (args.ContainsKey("context")) { ctx.Unpack((OSDMap)args["context"]); } AgentDestinationData data = CreateAgentDestinationData(); UnpackData(args, data, request); GridRegion destination = new GridRegion(); destination.RegionID = data.uuid; destination.RegionLocX = data.x; destination.RegionLocY = data.y; destination.RegionName = data.name; GridRegion gatekeeper = ExtractGatekeeper(data); AgentCircuitData aCircuit = new AgentCircuitData(); try { aCircuit.UnpackAgentCircuitData(args); } catch (Exception ex) { m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message); responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } GridRegion source = null; if (args.ContainsKey("source_uuid")) { source = new GridRegion(); source.RegionLocX = Int32.Parse(args["source_x"].AsString()); source.RegionLocY = Int32.Parse(args["source_y"].AsString()); source.RegionName = args["source_name"].AsString(); source.RegionID = UUID.Parse(args["source_uuid"].AsString()); if (args.ContainsKey("source_server_uri")) { source.RawServerURI = args["source_server_uri"].AsString(); } else { source.RawServerURI = null; } } OSDMap resp = new OSDMap(2); string reason = String.Empty; // This is the meaning of POST agent //m_regionClient.AdjustUserInformation(aCircuit); //bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); bool result = CreateAgent(source, gatekeeper, destination, aCircuit, data.flags, data.fromLogin, ctx, out reason); resp["reason"] = OSD.FromString(reason); resp["success"] = OSD.FromBoolean(result); // Let's also send out the IP address of the caller back to the caller (HG 1.5) resp["your_ip"] = OSD.FromString(GetCallerIP(request)); // TODO: add reason if not String.Empty? responsedata["int_response_code"] = HttpStatusCode.OK; responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); }
protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) { OSDMap args = WebUtils.GetOSDMap ((string)request["body"]); if (args == null) { responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } // retrieve the input arguments int x = 0, y = 0; UUID uuid = UUID.Zero; string regionname = string.Empty; uint teleportFlags = 0; if (args.ContainsKey ("destination_x") && args["destination_x"] != null) Int32.TryParse (args["destination_x"].AsString (), out x); else m_log.WarnFormat (" -- request didn't have destination_x"); if (args.ContainsKey ("destination_y") && args["destination_y"] != null) Int32.TryParse (args["destination_y"].AsString (), out y); else m_log.WarnFormat (" -- request didn't have destination_y"); if (args.ContainsKey ("destination_uuid") && args["destination_uuid"] != null) UUID.TryParse (args["destination_uuid"].AsString (), out uuid); if (args.ContainsKey ("destination_name") && args["destination_name"] != null) regionname = args["destination_name"].ToString (); if (args.ContainsKey ("teleport_flags") && args["teleport_flags"] != null) teleportFlags = args["teleport_flags"].AsUInteger (); GridRegion destination = new GridRegion (); destination.RegionID = uuid; destination.RegionLocX = x; destination.RegionLocY = y; destination.RegionName = regionname; AgentCircuitData aCircuit = new AgentCircuitData (); try { aCircuit.UnpackAgentCircuitData (args); } catch (Exception ex) { m_log.InfoFormat ("[AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message); responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } OSDMap resp = new OSDMap (2); string reason = String.Empty; // This is the meaning of POST agent //m_regionClient.AdjustUserInformation(aCircuit); //bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); bool result = CreateAgent (destination, aCircuit, teleportFlags, out reason); resp["reason"] = OSD.FromString (reason); resp["success"] = OSD.FromBoolean (result); // Let's also send out the IP address of the caller back to the caller (HG 1.5) resp["your_ip"] = OSD.FromString (GetCallerIP (request)); // TODO: add reason if not String.Empty? responsedata["int_response_code"] = HttpStatusCode.OK; responsedata["str_response_string"] = OSDParser.SerializeJsonString (resp); }
public void TestAgentCircuitDataOSDConversion() { AgentCircuitData Agent1Data = new AgentCircuitData(); Agent1Data.AgentID = AgentId; Agent1Data.Appearance = AvAppearance; Agent1Data.BaseFolder = BaseFolder; Agent1Data.CapsPath = CapsPath; Agent1Data.child = false; Agent1Data.ChildrenCapSeeds = ChildrenCapsPaths; Agent1Data.circuitcode = circuitcode; Agent1Data.firstname = firstname; Agent1Data.InventoryFolder = BaseFolder; Agent1Data.lastname = lastname; Agent1Data.SecureSessionID = SecureSessionId; Agent1Data.SessionID = SessionId; Agent1Data.startpos = StartPos; OSDMap map2; OSDMap map = Agent1Data.PackAgentCircuitData(); try { string str = OSDParser.SerializeJsonString(map); //System.Console.WriteLine(str); map2 = (OSDMap) OSDParser.DeserializeJson(str); } catch (System.NullReferenceException) { //spurious litjson errors :P map2 = map; Assert.That(1==1); return; } AgentCircuitData Agent2Data = new AgentCircuitData(); Agent2Data.UnpackAgentCircuitData(map2); Assert.That((Agent1Data.AgentID == Agent2Data.AgentID)); Assert.That((Agent1Data.BaseFolder == Agent2Data.BaseFolder)); Assert.That((Agent1Data.CapsPath == Agent2Data.CapsPath)); Assert.That((Agent1Data.child == Agent2Data.child)); Assert.That((Agent1Data.ChildrenCapSeeds.Count == Agent2Data.ChildrenCapSeeds.Count)); Assert.That((Agent1Data.circuitcode == Agent2Data.circuitcode)); Assert.That((Agent1Data.firstname == Agent2Data.firstname)); Assert.That((Agent1Data.InventoryFolder == Agent2Data.InventoryFolder)); Assert.That((Agent1Data.lastname == Agent2Data.lastname)); Assert.That((Agent1Data.SecureSessionID == Agent2Data.SecureSessionID)); Assert.That((Agent1Data.SessionID == Agent2Data.SessionID)); Assert.That((Agent1Data.startpos == Agent2Data.startpos)); /* Enable this once VisualParams go in the packing method for (int i = 0; i < 208; i++) Assert.That((Agent1Data.Appearance.VisualParams[i] == Agent2Data.Appearance.VisualParams[i])); */ }
public void HistoricalAgentCircuitDataOSDConversion() { string oldSerialization = "{\"agent_id\":\"522675bd-8214-40c1-b3ca-9c7f7fd170be\",\"base_folder\":\"c40b5f5f-476f-496b-bd69-b5a539c434d8\",\"caps_path\":\"http://www.opensimulator.org/Caps/Foo\",\"children_seeds\":[{\"handle\":\"18446744073709551615\",\"seed\":\"http://www.opensimulator.org/Caps/Foo2\"}],\"child\":false,\"circuit_code\":\"949030\",\"first_name\":\"CoolAvatarTest\",\"last_name\":\"test\",\"inventory_folder\":\"c40b5f5f-476f-496b-bd69-b5a539c434d8\",\"secure_session_id\":\"1e608e2b-0ddb-41f6-be0f-926f61cd3e0a\",\"session_id\":\"aa06f798-9d70-4bdb-9bbf-012a02ee2baf\",\"start_pos\":\"<5, 23, 125>\"}"; AgentCircuitData Agent1Data = new AgentCircuitData(); Agent1Data.AgentID = new UUID("522675bd-8214-40c1-b3ca-9c7f7fd170be"); Agent1Data.Appearance = AvAppearance; Agent1Data.BaseFolder = new UUID("c40b5f5f-476f-496b-bd69-b5a539c434d8"); Agent1Data.CapsPath = CapsPath; Agent1Data.child = false; Agent1Data.ChildrenCapSeeds = ChildrenCapsPaths; Agent1Data.circuitcode = circuitcode; Agent1Data.firstname = firstname; Agent1Data.InventoryFolder = new UUID("c40b5f5f-476f-496b-bd69-b5a539c434d8"); Agent1Data.lastname = lastname; Agent1Data.SecureSessionID = new UUID("1e608e2b-0ddb-41f6-be0f-926f61cd3e0a"); Agent1Data.SessionID = new UUID("aa06f798-9d70-4bdb-9bbf-012a02ee2baf"); Agent1Data.startpos = StartPos; OSDMap map2; try { map2 = (OSDMap) OSDParser.DeserializeJson(oldSerialization); AgentCircuitData Agent2Data = new AgentCircuitData(); Agent2Data.UnpackAgentCircuitData(map2); Assert.That((Agent1Data.AgentID == Agent2Data.AgentID)); Assert.That((Agent1Data.BaseFolder == Agent2Data.BaseFolder)); Assert.That((Agent1Data.CapsPath == Agent2Data.CapsPath)); Assert.That((Agent1Data.child == Agent2Data.child)); Assert.That((Agent1Data.ChildrenCapSeeds.Count == Agent2Data.ChildrenCapSeeds.Count)); Assert.That((Agent1Data.circuitcode == Agent2Data.circuitcode)); Assert.That((Agent1Data.firstname == Agent2Data.firstname)); Assert.That((Agent1Data.InventoryFolder == Agent2Data.InventoryFolder)); Assert.That((Agent1Data.lastname == Agent2Data.lastname)); Assert.That((Agent1Data.SecureSessionID == Agent2Data.SecureSessionID)); Assert.That((Agent1Data.SessionID == Agent2Data.SessionID)); Assert.That((Agent1Data.startpos == Agent2Data.startpos)); } catch (LitJson.JsonException) { //intermittant litjson errors :P Assert.That(1 == 1); } /* Enable this once VisualParams go in the packing method for (int i=0;i<208;i++) Assert.That((Agent1Data.Appearance.VisualParams[i] == Agent2Data.Appearance.VisualParams[i])); */ }
protected OSDMap OnMessageReceived(OSDMap message) { if (!message.ContainsKey("Method")) { return(null); } UUID AgentID = message["AgentID"].AsUUID(); ulong requestingRegion = message["RequestingRegion"].AsULong(); ICapsService capsService = m_registry.RequestModuleInterface <ICapsService>(); if (capsService == null) { //m_log.Info("[AgentProcessing]: Failed OnMessageReceived ICapsService is null"); return(new OSDMap()); } IClientCapsService clientCaps = capsService.GetClientCapsService(AgentID); IRegionClientCapsService regionCaps = null; if (clientCaps != null) { regionCaps = clientCaps.GetCapsService(requestingRegion); } if (message["Method"] == "LogoutRegionAgents") { LogOutAllAgentsForRegion(requestingRegion); } else if (message["Method"] == "RegionIsOnline") //This gets fired when the scene is fully finished starting up { //Log out all the agents first, then add any child agents that should be in this region LogOutAllAgentsForRegion(requestingRegion); IGridService GridService = m_registry.RequestModuleInterface <IGridService>(); if (GridService != null) { int x, y; Util.UlongToInts(requestingRegion, out x, out y); GridRegion requestingGridRegion = GridService.GetRegionByPosition(UUID.Zero, x, y); if (requestingGridRegion != null) { EnableChildAgentsForRegion(requestingGridRegion); } } } else if (message["Method"] == "DisableSimulator") { //KILL IT! if (regionCaps == null || clientCaps == null) { return(null); } regionCaps.Close(); clientCaps.RemoveCAPS(requestingRegion); } else if (message["Method"] == "ArrivedAtDestination") { if (regionCaps == null || clientCaps == null) { return(null); } //Recieved a callback if (clientCaps.InTeleport) //Only set this if we are in a teleport, // otherwise (such as on login), this won't check after the first tp! { clientCaps.CallbackHasCome = true; } regionCaps.Disabled = false; //The agent is getting here for the first time (eg. login) OSDMap body = ((OSDMap)message["Message"]); //Parse the OSDMap int DrawDistance = body["DrawDistance"].AsInteger(); AgentCircuitData circuitData = new AgentCircuitData(); circuitData.UnpackAgentCircuitData((OSDMap)body["Circuit"]); //Now do the creation EnableChildAgents(AgentID, requestingRegion, DrawDistance, circuitData); } else if (message["Method"] == "CancelTeleport") { if (regionCaps == null || clientCaps == null) { return(null); } //Only the region the client is root in can do this IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService(); if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle) { //The user has requested to cancel the teleport, stop them. clientCaps.RequestToCancelTeleport = true; regionCaps.Disabled = false; } } else if (message["Method"] == "AgentLoggedOut") { //ONLY if the agent is root do we even consider it if (regionCaps != null) { if (regionCaps.RootAgent) { LogoutAgent(regionCaps); } } } else if (message["Method"] == "SendChildAgentUpdate") { if (regionCaps == null || clientCaps == null) { return(null); } IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService(); if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle) { OSDMap body = ((OSDMap)message["Message"]); AgentPosition pos = new AgentPosition(); pos.Unpack((OSDMap)body["AgentPos"]); SendChildAgentUpdate(pos, regionCaps); regionCaps.Disabled = false; } } else if (message["Method"] == "TeleportAgent") { if (regionCaps == null || clientCaps == null) { return(null); } IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService(); if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle) { OSDMap body = ((OSDMap)message["Message"]); GridRegion destination = new GridRegion(); destination.FromOSD((OSDMap)body["Region"]); uint TeleportFlags = body["TeleportFlags"].AsUInteger(); int DrawDistance = body["DrawDistance"].AsInteger(); AgentCircuitData Circuit = new AgentCircuitData(); Circuit.UnpackAgentCircuitData((OSDMap)body["Circuit"]); AgentData AgentData = new AgentData(); AgentData.Unpack((OSDMap)body["AgentData"]); regionCaps.Disabled = false; OSDMap result = new OSDMap(); string reason = ""; result["Success"] = TeleportAgent(destination, TeleportFlags, DrawDistance, Circuit, AgentData, AgentID, requestingRegion, out reason); result["Reason"] = reason; return(result); } } else if (message["Method"] == "CrossAgent") { if (regionCaps == null || clientCaps == null) { return(null); } if (clientCaps.GetRootCapsService().RegionHandle == regionCaps.RegionHandle) { //This is a simulator message that tells us to cross the agent OSDMap body = ((OSDMap)message["Message"]); Vector3 pos = body["Pos"].AsVector3(); Vector3 Vel = body["Vel"].AsVector3(); GridRegion Region = new GridRegion(); Region.FromOSD((OSDMap)body["Region"]); AgentCircuitData Circuit = new AgentCircuitData(); Circuit.UnpackAgentCircuitData((OSDMap)body["Circuit"]); AgentData AgentData = new AgentData(); AgentData.Unpack((OSDMap)body["AgentData"]); regionCaps.Disabled = false; OSDMap result = new OSDMap(); string reason = ""; result["Success"] = CrossAgent(Region, pos, Vel, Circuit, AgentData, AgentID, requestingRegion, out reason); result["Reason"] = reason; return(result); } } return(null); }
protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) { if (m_safemode) { // Authentication string authority = string.Empty; string authToken = string.Empty; if (!GetAuthentication(request, out authority, out authToken)) { m_log.InfoFormat("[REST COMMS]: Authentication failed for agent message {0}", request["uri"]); responsedata["int_response_code"] = 403; responsedata["str_response_string"] = "Forbidden"; return; } if (!VerifyKey(id, authority, authToken)) { m_log.InfoFormat("[REST COMMS]: Authentication failed for agent message {0}", request["uri"]); responsedata["int_response_code"] = 403; responsedata["str_response_string"] = "Forbidden"; return; } m_log.DebugFormat("[REST COMMS]: Authentication succeeded for {0}", id); } OSDMap args = RegionClient.GetOSDMap((string)request["body"]); if (args == null) { responsedata["int_response_code"] = 400; responsedata["str_response_string"] = "false"; return; } // retrieve the regionhandle ulong regionhandle = 0; if (args["destination_handle"] != null) { UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); } AgentCircuitData aCircuit = new AgentCircuitData(); try { aCircuit.UnpackAgentCircuitData(args); } catch (Exception ex) { m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildCreate message {0}", ex.Message); return; } OSDMap resp = new OSDMap(2); string reason = String.Empty; // This is the meaning of POST agent m_regionClient.AdjustUserInformation(aCircuit); bool result = m_localBackend.SendCreateChildAgent(regionhandle, aCircuit, out reason); resp["reason"] = OSD.FromString(reason); resp["success"] = OSD.FromBoolean(result); // TODO: add reason if not String.Empty? responsedata["int_response_code"] = 200; responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); }
protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) { OSDMap args = Utils.GetOSDMap((string)request["body"]); if (args == null) { responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } // retrieve the input arguments int x = 0, y = 0; UUID uuid = UUID.Zero; string regionname = string.Empty; string gatekeeper_host = string.Empty; int gatekeeper_port = 0; if (args.ContainsKey("gatekeeper_host") && args["gatekeeper_host"] != null) { gatekeeper_host = args["gatekeeper_host"].AsString(); } if (args.ContainsKey("gatekeeper_port") && args["gatekeeper_port"] != null) { Int32.TryParse(args["gatekeeper_port"].AsString(), out gatekeeper_port); } GridRegion gatekeeper = new GridRegion(); gatekeeper.ExternalHostName = gatekeeper_host; gatekeeper.HttpPort = (uint)gatekeeper_port; gatekeeper.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); if (args.ContainsKey("destination_x") && args["destination_x"] != null) { Int32.TryParse(args["destination_x"].AsString(), out x); } else { m_log.WarnFormat(" -- request didn't have destination_x"); } if (args.ContainsKey("destination_y") && args["destination_y"] != null) { Int32.TryParse(args["destination_y"].AsString(), out y); } else { m_log.WarnFormat(" -- request didn't have destination_y"); } if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) { UUID.TryParse(args["destination_uuid"].AsString(), out uuid); } if (args.ContainsKey("destination_name") && args["destination_name"] != null) { regionname = args["destination_name"].ToString(); } GridRegion destination = new GridRegion(); destination.RegionID = uuid; destination.RegionLocX = x; destination.RegionLocY = y; destination.RegionName = regionname; AgentCircuitData aCircuit = new AgentCircuitData(); try { aCircuit.UnpackAgentCircuitData(args); } catch (Exception ex) { m_log.InfoFormat("[HOME AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message); responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } OSDMap resp = new OSDMap(2); string reason = String.Empty; bool result = m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, out reason); resp["reason"] = OSD.FromString(reason); resp["success"] = OSD.FromBoolean(result); // TODO: add reason if not String.Empty? responsedata["int_response_code"] = HttpStatusCode.OK; responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); }
protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) { OSDMap args = Utils.GetOSDMap((string)request["body"]); if (args == null) { responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } // retrieve the input arguments int x = 0, y = 0; UUID uuid = UUID.Zero; string regionname = string.Empty; uint teleportFlags = 0; if (args.ContainsKey("destination_x") && args["destination_x"] != null) { Int32.TryParse(args["destination_x"].AsString(), out x); } else { m_log.WarnFormat(" -- request didn't have destination_x"); } if (args.ContainsKey("destination_y") && args["destination_y"] != null) { Int32.TryParse(args["destination_y"].AsString(), out y); } else { m_log.WarnFormat(" -- request didn't have destination_y"); } if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) { UUID.TryParse(args["destination_uuid"].AsString(), out uuid); } if (args.ContainsKey("destination_name") && args["destination_name"] != null) { regionname = args["destination_name"].ToString(); } if (args.ContainsKey("teleport_flags") && args["teleport_flags"] != null) { teleportFlags = args["teleport_flags"].AsUInteger(); } GridRegion destination = new GridRegion(); destination.RegionID = uuid; destination.RegionLocX = x; destination.RegionLocY = y; destination.RegionName = regionname; AgentCircuitData aCircuit = new AgentCircuitData(); try { aCircuit.UnpackAgentCircuitData(args); } catch (Exception ex) { m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message); responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } OSDMap resp = new OSDMap(2); string reason = String.Empty; // This is the meaning of POST agent //m_regionClient.AdjustUserInformation(aCircuit); //bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); bool result = CreateAgent(destination, aCircuit, teleportFlags, out reason); resp["reason"] = OSD.FromString(reason); resp["success"] = OSD.FromBoolean(result); // Let's also send out the IP address of the caller back to the caller (HG 1.5) resp["your_ip"] = OSD.FromString(GetCallerIP(request)); // TODO: add reason if not String.Empty? responsedata["int_response_code"] = HttpStatusCode.OK; responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); }
protected void DoAgentPost(OSDMap args, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentID) { OSD tmpOSD; EntityTransferContext ctx = new EntityTransferContext(); if (args.TryGetValue("context", out tmpOSD) && tmpOSD is OSDMap) { ctx.Unpack((OSDMap)tmpOSD); } AgentDestinationData data = CreateAgentDestinationData(); UnpackData(args, data); GridRegion destination = new GridRegion(); destination.RegionID = data.uuid; destination.RegionLocX = data.x; destination.RegionLocY = data.y; destination.RegionName = data.name; GridRegion gatekeeper = ExtractGatekeeper(data); AgentCircuitData aCircuit = new AgentCircuitData(); try { aCircuit.UnpackAgentCircuitData(args); } catch (Exception ex) { m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message); httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; httpResponse.RawBuffer = Util.UTF8.GetBytes("false"); return; } GridRegion source = null; if (args.TryGetValue("source_uuid", out tmpOSD)) { source = new GridRegion(); source.RegionID = UUID.Parse(tmpOSD.AsString()); source.RegionLocX = Int32.Parse(args["source_x"].AsString()); source.RegionLocY = Int32.Parse(args["source_y"].AsString()); source.RegionName = args["source_name"].AsString(); if (args.TryGetValue("source_server_uri", out tmpOSD)) { source.RawServerURI = tmpOSD.AsString(); } else { source.RawServerURI = null; } } OSDMap resp = new OSDMap(2); string reason = String.Empty; bool result = CreateAgent(source, gatekeeper, destination, aCircuit, data.flags, data.fromLogin, ctx, out reason); resp["reason"] = OSD.FromString(reason); resp["success"] = OSD.FromBoolean(result); // Let's also send out the IP address of the caller back to the caller (HG 1.5) resp["your_ip"] = OSD.FromString(httpRequest.RemoteIPEndPoint.Address.ToString()); httpResponse.StatusCode = (int)HttpStatusCode.OK; httpResponse.RawBuffer = Util.UTF8.GetBytes(OSDParser.SerializeJsonString(resp)); }
/// <summary> /// Add the given event into the client's queue so that it is sent on the next /// </summary> /// <param name="ev"></param> /// <param name="avatarID"></param> /// <returns></returns> public bool Enqueue(OSD ev) { try { if (ev == null) return false; //Check the messages to pull out ones that are creating or destroying CAPS in this or other regions if (ev.Type == OSDType.Map) { OSDMap map = (OSDMap)ev; if (map.ContainsKey("message") && map["message"] == "DisableSimulator") { //Let this pass through, after the next event queue pass we can remove it //m_service.ClientCaps.RemoveCAPS(m_service.RegionHandle); } else if (map.ContainsKey("message") && map["message"] == "EnableChildAgents") { //Some notes on this message: // 1) This is a region > CapsService message ONLY, this should never be sent to the client! // 2) This just enables child agents in the regions given, as the region cannot do it, // as regions do not have the ability to know what Cap Urls other regions have. // 3) We could do more checking here, but we don't really 'have' to at this point. // If the sim was able to get it past the password checks and everything, // it should be able to add the neighbors here. We could do the neighbor finding here // as well, but it's not necessary at this time. OSDMap body = ((OSDMap)map["body"]); //Parse the OSDMap int DrawDistance = body["DrawDistance"].AsInteger(); AgentCircuitData circuitData = new AgentCircuitData(); circuitData.UnpackAgentCircuitData((OSDMap)body["Circuit"]); OSDArray neighborsArray = (OSDArray)body["Regions"]; GridRegion[] neighbors = new GridRegion[neighborsArray.Count]; int i = 0; foreach (OSD r in neighborsArray) { GridRegion region = new GridRegion(); region.FromOSD((OSDMap)r); neighbors[i] = region; i++; } uint TeleportFlags = body["TeleportFlags"].AsUInteger(); AgentData data = null; if (body.ContainsKey("AgentData")) { data = new AgentData(); data.Unpack((OSDMap)body["AgentData"]); } byte[] IPAddress = null; if(body.ContainsKey("IPAddress")) IPAddress = body["IPAddress"].AsBinary(); int Port = 0; if (body.ContainsKey("Port")) Port = body["Port"].AsInteger(); //Now do the creation //Don't send it to the client at all, so return here return EnableChildAgents(DrawDistance, neighbors, circuitData, TeleportFlags, data, IPAddress, Port); } else if (map.ContainsKey("message") && map["message"] == "EstablishAgentCommunication") { string SimSeedCap = ((OSDMap)map["body"])["seed-capability"].AsString(); ulong regionHandle = ((OSDMap)map["body"])["region-handle"].AsULong(); string newSeedCap = CapsUtil.GetCapsSeedPath(CapsUtil.GetRandomCapsObjectPath()); IRegionClientCapsService otherRegionService = m_service.ClientCaps.GetOrCreateCapsService(regionHandle, newSeedCap, SimSeedCap); //ONLY UPDATE THE SIM SEED HERE //DO NOT PASS THE newSeedCap FROM ABOVE AS IT WILL BREAK THIS CODE // AS THE CLIENT EXPECTS THE SAME CAPS SEED IF IT HAS BEEN TO THE REGION BEFORE // AND FORCE UPDATING IT HERE WILL BREAK IT. otherRegionService.AddSEEDCap("", SimSeedCap, otherRegionService.Password); ((OSDMap)map["body"])["seed-capability"] = otherRegionService.CapsUrl; } else if (map.ContainsKey("message") && map["message"] == "CrossedRegion") { OSDMap infoMap = ((OSDMap)((OSDArray)((OSDMap)map["body"])["RegionData"])[0]); string SimSeedCap = infoMap["SeedCapability"].AsString(); ulong regionHandle = infoMap["RegionHandle"].AsULong(); string newSeedCap = CapsUtil.GetCapsSeedPath(CapsUtil.GetRandomCapsObjectPath()); IRegionClientCapsService otherRegionService = m_service.ClientCaps.GetOrCreateCapsService(regionHandle, newSeedCap, SimSeedCap); //ONLY UPDATE THE SIM SEED HERE //DO NOT PASS THE newSeedCap FROM ABOVE AS IT WILL BREAK THIS CODE // AS THE CLIENT EXPECTS THE SAME CAPS SEED IF IT HAS BEEN TO THE REGION BEFORE // AND FORCE UPDATING IT HERE WILL BREAK IT. otherRegionService.AddSEEDCap("", SimSeedCap, otherRegionService.Password); //Now tell the client about it correctly ((OSDMap)((OSDArray)((OSDMap)map["body"])["RegionData"])[0])["SeedCapability"] = otherRegionService.CapsUrl; } else if (map.ContainsKey("message") && map["message"] == "TeleportFinish") { OSDMap infoMap = ((OSDMap)((OSDArray)((OSDMap)map["body"])["Info"])[0]); string SimSeedCap = infoMap["SeedCapability"].AsString(); ulong regionHandle = infoMap["RegionHandle"].AsULong(); string newSeedCap = CapsUtil.GetCapsSeedPath(CapsUtil.GetRandomCapsObjectPath()); IRegionClientCapsService otherRegionService = m_service.ClientCaps.GetOrCreateCapsService(regionHandle, newSeedCap, SimSeedCap); //ONLY UPDATE THE SIM SEED HERE //DO NOT PASS THE newSeedCap FROM ABOVE AS IT WILL BREAK THIS CODE // AS THE CLIENT EXPECTS THE SAME CAPS SEED IF IT HAS BEEN TO THE REGION BEFORE // AND FORCE UPDATING IT HERE WILL BREAK IT. otherRegionService.AddSEEDCap("", SimSeedCap, otherRegionService.Password); //Now tell the client about it correctly ((OSDMap)((OSDArray)((OSDMap)map["body"])["Info"])[0])["SeedCapability"] = otherRegionService.CapsUrl; } } lock (queue) queue.Enqueue(ev); } catch (NullReferenceException e) { m_log.Error("[EVENTQUEUE] Caught exception: " + e); return false; } return true; }
protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) { OSDMap args = Utils.GetOSDMap((string)request["body"]); if (args == null) { responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } // retrieve the input arguments int x = 0, y = 0; UUID uuid = UUID.Zero; string regionname = string.Empty; string gatekeeper_host = string.Empty; int gatekeeper_port = 0; IPEndPoint client_ipaddress = null; if (args.ContainsKey("gatekeeper_host") && args["gatekeeper_host"] != null) { gatekeeper_host = args["gatekeeper_host"].AsString(); } if (args.ContainsKey("gatekeeper_port") && args["gatekeeper_port"] != null) { Int32.TryParse(args["gatekeeper_port"].AsString(), out gatekeeper_port); } GridRegion gatekeeper = new GridRegion(); gatekeeper.ExternalHostName = gatekeeper_host; gatekeeper.HttpPort = (uint)gatekeeper_port; gatekeeper.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); if (args.ContainsKey("destination_x") && args["destination_x"] != null) { Int32.TryParse(args["destination_x"].AsString(), out x); } else { m_log.WarnFormat(" -- request didn't have destination_x"); } if (args.ContainsKey("destination_y") && args["destination_y"] != null) { Int32.TryParse(args["destination_y"].AsString(), out y); } else { m_log.WarnFormat(" -- request didn't have destination_y"); } if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null) { UUID.TryParse(args["destination_uuid"].AsString(), out uuid); } if (args.ContainsKey("destination_name") && args["destination_name"] != null) { regionname = args["destination_name"].ToString(); } if (args.ContainsKey("client_ip") && args["client_ip"] != null) { string ip_str = args["client_ip"].ToString(); try { string callerIP = GetCallerIP(request); // Verify if this caller has authority to send the client IP if (callerIP == m_LoginServerIP) { client_ipaddress = new IPEndPoint(IPAddress.Parse(ip_str), 0); } else // leaving this for now, but this warning should be removed { m_log.WarnFormat("[HOME AGENT HANDLER]: Unauthorized machine {0} tried to set client ip to {1}", callerIP, ip_str); } } catch { m_log.DebugFormat("[HOME AGENT HANDLER]: Exception parsing client ip address from {0}", ip_str); } } GridRegion destination = new GridRegion(); destination.RegionID = uuid; destination.RegionLocX = x; destination.RegionLocY = y; destination.RegionName = regionname; AgentCircuitData aCircuit = new AgentCircuitData(); try { aCircuit.UnpackAgentCircuitData(args); } catch (Exception ex) { m_log.InfoFormat("[HOME AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message); responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } OSDMap resp = new OSDMap(2); string reason = String.Empty; bool result = m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, client_ipaddress, out reason); resp["reason"] = OSD.FromString(reason); resp["success"] = OSD.FromBoolean(result); // TODO: add reason if not String.Empty? responsedata["int_response_code"] = HttpStatusCode.OK; responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); }
/// <summary> /// Add the given event into the client's queue so that it is sent on the next /// </summary> /// <param name="ev"></param> /// <param name="avatarID"></param> /// <returns></returns> public bool Enqueue(OSD ev) { try { if (ev == null) return false; //Check the messages to pull out ones that are creating or destroying CAPS in this or other regions if (ev.Type == OSDType.Map) { OSDMap map = (OSDMap)ev; if (map.ContainsKey("message") && map["message"] == "DisableSimulator") { //Let this pass through, after the next event queue pass we can remove it //m_service.ClientCaps.RemoveCAPS(m_service.RegionHandle); if (!m_service.Disabled) { m_service.Disabled = true; OSDMap body = ((OSDMap)map["body"]); //See whether this needs sent to the client or not if (!body["KillClient"].AsBoolean()) { //This is very risky... but otherwise the user doesn't get cleaned up... m_service.ClientCaps.RemoveCAPS(m_service.RegionHandle); return true; } } else //Don't enqueue multiple times return true; } else if (map.ContainsKey("message") && map["message"] == "ArrivedAtDestination") { //Recieved a callback m_service.ClientCaps.CallbackHasCome = true; m_service.Disabled = false; //Don't send it to the client return true; } else if (map.ContainsKey("message") && map["message"] == "CancelTeleport") { //The user has requested to cancel the teleport, stop them. m_service.ClientCaps.RequestToCancelTeleport = true; m_service.Disabled = false; //Don't send it to the client return true; } else if (map.ContainsKey("message") && map["message"] == "SendChildAgentUpdate") { OSDMap body = ((OSDMap)map["body"]); AgentPosition pos = new AgentPosition(); pos.Unpack((OSDMap)body["AgentPos"]); UUID region = body["Region"].AsUUID(); SendChildAgentUpdate(pos, region); m_service.Disabled = false; //Don't send to the client return true; } else if (map.ContainsKey("message") && map["message"] == "TeleportAgent") { OSDMap body = ((OSDMap)map["body"]); GridRegion destination = new GridRegion(); destination.FromOSD((OSDMap)body["Region"]); uint TeleportFlags = body["TeleportFlags"].AsUInteger(); int DrawDistance = body["DrawDistance"].AsInteger(); AgentCircuitData Circuit = new AgentCircuitData(); Circuit.UnpackAgentCircuitData((OSDMap)body["Circuit"]); AgentData AgentData = new AgentData(); AgentData.Unpack((OSDMap)body["AgentData"]); m_service.Disabled = false; //Don't send to the client return TeleportAgent(destination, TeleportFlags, DrawDistance, Circuit, AgentData); } else if (map.ContainsKey("message") && map["message"] == "CrossAgent") { //This is a simulator message that tells us to cross the agent OSDMap body = ((OSDMap)map["body"]); Vector3 pos = body["Pos"].AsVector3(); Vector3 Vel = body["Vel"].AsVector3(); GridRegion Region = new GridRegion(); Region.FromOSD((OSDMap)body["Region"]); AgentCircuitData Circuit = new AgentCircuitData(); Circuit.UnpackAgentCircuitData((OSDMap)body["Circuit"]); AgentData AgentData = new AgentData(); AgentData.Unpack((OSDMap)body["AgentData"]); m_service.Disabled = false; //Client doesn't get this return CrossAgent(Region, pos, Vel, Circuit, AgentData); } else if (map.ContainsKey("message") && map["message"] == "EnableChildAgents") { //Some notes on this message: // 1) This is a region > CapsService message ONLY, this should never be sent to the client! // 2) This just enables child agents in the regions given, as the region cannot do it, // as regions do not have the ability to know what Cap Urls other regions have. // 3) We could do more checking here, but we don't really 'have' to at this point. // If the sim was able to get it past the password checks and everything, // it should be able to add the neighbors here. We could do the neighbor finding here // as well, but it's not necessary at this time. OSDMap body = ((OSDMap)map["body"]); //Parse the OSDMap int DrawDistance = body["DrawDistance"].AsInteger(); AgentCircuitData circuitData = new AgentCircuitData(); circuitData.UnpackAgentCircuitData((OSDMap)body["Circuit"]); //Now do the creation //Don't send it to the client at all, so return here return EnableChildAgents(DrawDistance, circuitData); } else if (map.ContainsKey("message") && map["message"] == "EstablishAgentCommunication") { string SimSeedCap = ((OSDMap)map["body"])["seed-capability"].AsString(); ulong regionHandle = ((OSDMap)map["body"])["region-handle"].AsULong(); string newSeedCap = CapsUtil.GetCapsSeedPath(CapsUtil.GetRandomCapsObjectPath()); IRegionClientCapsService otherRegionService = m_service.ClientCaps.GetOrCreateCapsService(regionHandle, newSeedCap, SimSeedCap); //ONLY UPDATE THE SIM SEED HERE //DO NOT PASS THE newSeedCap FROM ABOVE AS IT WILL BREAK THIS CODE // AS THE CLIENT EXPECTS THE SAME CAPS SEED IF IT HAS BEEN TO THE REGION BEFORE // AND FORCE UPDATING IT HERE WILL BREAK IT. otherRegionService.AddSEEDCap("", SimSeedCap, otherRegionService.Password); ((OSDMap)map["body"])["seed-capability"] = otherRegionService.CapsUrl; } else if (map.ContainsKey("message") && map["message"] == "CrossedRegion") { OSDMap infoMap = ((OSDMap)((OSDArray)((OSDMap)map["body"])["RegionData"])[0]); string SimSeedCap = infoMap["SeedCapability"].AsString(); ulong regionHandle = infoMap["RegionHandle"].AsULong(); string newSeedCap = CapsUtil.GetCapsSeedPath(CapsUtil.GetRandomCapsObjectPath()); IRegionClientCapsService otherRegionService = m_service.ClientCaps.GetOrCreateCapsService(regionHandle, newSeedCap, SimSeedCap); //ONLY UPDATE THE SIM SEED HERE //DO NOT PASS THE newSeedCap FROM ABOVE AS IT WILL BREAK THIS CODE // AS THE CLIENT EXPECTS THE SAME CAPS SEED IF IT HAS BEEN TO THE REGION BEFORE // AND FORCE UPDATING IT HERE WILL BREAK IT. otherRegionService.AddSEEDCap("", SimSeedCap, otherRegionService.Password); m_service.Disabled = false; //Now tell the client about it correctly ((OSDMap)((OSDArray)((OSDMap)map["body"])["RegionData"])[0])["SeedCapability"] = otherRegionService.CapsUrl; } else if (map.ContainsKey("message") && map["message"] == "TeleportFinish") { OSDMap infoMap = ((OSDMap)((OSDArray)((OSDMap)map["body"])["Info"])[0]); string SimSeedCap = infoMap["SeedCapability"].AsString(); ulong regionHandle = infoMap["RegionHandle"].AsULong(); string newSeedCap = CapsUtil.GetCapsSeedPath(CapsUtil.GetRandomCapsObjectPath()); IRegionClientCapsService otherRegionService = m_service.ClientCaps.GetOrCreateCapsService(regionHandle, newSeedCap, SimSeedCap); //ONLY UPDATE THE SIM SEED HERE //DO NOT PASS THE newSeedCap FROM ABOVE AS IT WILL BREAK THIS CODE // AS THE CLIENT EXPECTS THE SAME CAPS SEED IF IT HAS BEEN TO THE REGION BEFORE // AND FORCE UPDATING IT HERE WILL BREAK IT. otherRegionService.AddSEEDCap("", SimSeedCap, otherRegionService.Password); m_service.Disabled = false; //Now tell the client about it correctly ((OSDMap)((OSDArray)((OSDMap)map["body"])["Info"])[0])["SeedCapability"] = otherRegionService.CapsUrl; } } lock (queue) queue.Enqueue(ev); } catch (NullReferenceException e) { m_log.Error("[EVENTQUEUE] Caught exception: " + e); return false; } return true; }