public virtual bool CreateAgent(GridRegion destination, ref AgentCircuitData aCircuit, uint teleportFlags, AgentData data, out string reason) { reason = String.Empty; // Try local first if (m_localBackend.CreateAgent(destination, ref aCircuit, teleportFlags, data, out reason)) return true; reason = String.Empty; string uri = MakeUri(destination, true) + aCircuit.AgentID + "/"; try { OSDMap args = aCircuit.PackAgentCircuitData(); args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); args["destination_name"] = OSD.FromString(destination.RegionName); args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); args["teleport_flags"] = OSD.FromString(teleportFlags.ToString()); if(data != null) args["agent_data"] = data.Pack(); OSDMap result = WebUtils.PostToService (uri, args, true, false); OSDMap results = WebUtils.GetOSDMap(result["_RawResult"].AsString()); //Pull out the result and set it as the reason if (results == null) return false; reason = results["reason"] != null ? results["reason"].AsString() : ""; if (result["Success"].AsBoolean()) { //Not right... don't return true except for opensim combatibility :/ if (reason == "") return true; try { OSDMap responseMap = (OSDMap)OSDParser.DeserializeJson(reason); if (responseMap.ContainsKey("Reason")) reason = responseMap["Reason"].AsString(); return responseMap["Success"].AsBoolean(); } catch { //Not right... don't return true except for opensim combatibility :/ return true; } } reason = result["Message"] != null ? result["Message"].AsString() : "error"; return false; } catch (Exception e) { m_log.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e.ToString()); reason = e.Message; } return false; }
public void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq) { if (reg == null || finalDestination == null) { sp.ControllingClient.SendTeleportFailed("Unable to locate destination"); return; } m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Request Teleport to {0} ({1}) {2}/{3}", reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position); uint newRegionX = (uint)(reg.RegionHandle >> 40); uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8); ulong destinationHandle = finalDestination.RegionHandle; // Let's do DNS resolution only once in this process, please! // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, // it's actually doing a lot of work. IPEndPoint endPoint = finalDestination.ExternalEndPoint; if (endPoint.Address != null) { // Fixing a bug where teleporting while sitting results in the avatar ending up removed from // both regions if (sp.ParentID != (uint)0) sp.StandUp(); if (!sp.ValidateAttachments()) m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for teleport of {0} from {1} to {2}. Continuing.", sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName); // if (!sp.ValidateAttachments()) // { // sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); // return; // } string reason; string version; if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out version, out reason)) { sp.ControllingClient.SendTeleportFailed("Teleport failed: " + reason); return; } m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Destination is running version {0}", version); sp.ControllingClient.SendTeleportStart(teleportFlags); // the avatar.Close below will clear the child region list. We need this below for (possibly) // closing the child agents, so save it here (we need a copy as it is Clear()-ed). //List<ulong> childRegions = avatar.KnownRegionHandles; // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport // failure at this point (unlike a border crossing failure). So perhaps this can never fail // once we reach here... //avatar.Scene.RemoveCapsHandler(avatar.UUID); string capsPath = String.Empty; AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); agentCircuit.startpos = position; agentCircuit.child = true; agentCircuit.Appearance = sp.Appearance; if (currentAgentCircuit != null) { agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs; agentCircuit.IPAddress = currentAgentCircuit.IPAddress; agentCircuit.Viewer = currentAgentCircuit.Viewer; agentCircuit.Channel = currentAgentCircuit.Channel; agentCircuit.Mac = currentAgentCircuit.Mac; agentCircuit.Id0 = currentAgentCircuit.Id0; } if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY)) { // brand new agent, let's create a new caps seed agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); } // Let's create an agent there if one doesn't exist yet. bool logout = false; if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) { sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", reason)); return; } // OK, it got this agent. Let's close some child agents sp.CloseChildAgents(newRegionX, newRegionY); IClientIPEndpoint ipepClient; if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY)) { //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); #region IP Translation for NAT // Uses ipepClient above if (sp.ClientView.TryGet(out ipepClient)) { endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); } #endregion capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); if (eq != null) { eq.EnableSimulator(destinationHandle, endPoint, sp.UUID); // ES makes the client send a UseCircuitCode message to the destination, // which triggers a bunch of things there. // So let's wait Thread.Sleep(200); eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); } else { sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); } } else { agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); } SetInTransit(sp.UUID); // Let's send a full update of the agent. This is a synchronous call. AgentData agent = new AgentData(); sp.CopyTo(agent); agent.Position = position; SetCallbackURL(agent, sp.Scene.RegionInfo); //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Updating agent..."); if (!UpdateAgent(reg, finalDestination, agent)) { // Region doesn't take it m_log.WarnFormat( "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1}. Returning avatar to source region.", sp.Name, finalDestination.RegionName); Fail(sp, finalDestination); return; } sp.ControllingClient.SendTeleportProgress(teleportFlags | (uint)TeleportFlags.DisableCancel, "sending_dest"); m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID); if (eq != null) { eq.TeleportFinishEvent(destinationHandle, 13, endPoint, 0, teleportFlags, capsPath, sp.UUID); } else { sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, teleportFlags, capsPath); } // Let's set this to true tentatively. This does not trigger OnChildAgent sp.IsChildAgent = true; // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation // that the client contacted the destination before we close things here. if (!WaitForCallback(sp.UUID)) { m_log.WarnFormat( "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} failed due to no callback from destination region. Returning avatar to source region.", sp.Name, finalDestination.RegionName); Fail(sp, finalDestination); return; } // For backwards compatibility if (version == "Unknown" || version == string.Empty) { // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Old simulator, sending attachments one by one..."); CrossAttachmentsIntoNewRegion(finalDestination, sp, true); } // May need to logout or other cleanup AgentHasMovedAway(sp, logout); // Well, this is it. The agent is over there. KillEntity(sp.Scene, sp.LocalId); // Now let's make it officially a child agent sp.MakeChildAgent(); // sp.Scene.CleanDroppedAttachments(); // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone if (NeedsClosing(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) { Thread.Sleep(5000); sp.Close(); sp.Scene.IncomingCloseAgent(sp.UUID); } else { // now we have a child agent in this region. sp.IsInTransit = false; // not sure :( sp.Reset(); } // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! if (sp.Scene.NeedSceneCacheClear(sp.UUID)) { m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed", sp.UUID); } } else { sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); } }
public static OSDMap CrossAgent(GridRegion crossingRegion, Vector3 pos, Vector3 velocity, AgentCircuitData circuit, AgentData cAgent, ulong RequestingRegion) { OSDMap llsdBody = new OSDMap(); llsdBody.Add("Pos", pos); llsdBody.Add("Vel", velocity); llsdBody.Add("Region", crossingRegion.ToOSD()); llsdBody.Add("Circuit", circuit.PackAgentCircuitData()); llsdBody.Add("AgentData", cAgent.Pack()); return buildEvent("CrossAgent", llsdBody, circuit.AgentID, RequestingRegion); }
public bool UpdateAgent(GridRegion destination, AgentData cAgentData) { if (destination == null) return false; bool retVal = false; foreach (Scene s in m_sceneList) { IEntityTransferModule transferModule = s.RequestModuleInterface<IEntityTransferModule> (); if(transferModule != null) if(retVal) transferModule.IncomingChildAgentDataUpdate (s, cAgentData); else retVal = transferModule.IncomingChildAgentDataUpdate (s, cAgentData); } // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); return retVal; }
/** * Agent-related communications */ public bool CreateAgent(GridRegion destination, ref AgentCircuitData aCircuit, uint teleportFlags, AgentData data, out string reason) { if (destination == null) { reason = "Given destination was null"; m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: CreateAgent was given a null destination"); return false; } foreach (Scene s in m_sceneList) { if (s.RegionInfo.RegionID == destination.RegionID) { //m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName); if (data != null) UpdateAgent(destination, data); IEntityTransferModule transferModule = s.RequestModuleInterface<IEntityTransferModule> (); if (transferModule != null) return transferModule.NewUserConnection (s, aCircuit, teleportFlags, out reason); } } m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Did not find region {0} for CreateAgent", destination.RegionName); OSDMap map = new OSDMap(); map["Reason"] = "Did not find region " + destination.RegionName; map["Success"] = false; reason = OSDParser.SerializeJsonString(map); return false; }
public virtual void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq) { sp.ControllingClient.SendTeleportProgress(teleportFlags, "sending_dest"); if (reg == null || finalDestination == null) { sp.ControllingClient.SendTeleportFailed("Unable to locate destination"); return; } m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3}", reg.ExternalHostName, reg.HttpPort, finalDestination.RegionName, position); uint newRegionX = (uint)(reg.RegionHandle >> 40); uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8); ulong destinationHandle = finalDestination.RegionHandle; // Let's do DNS resolution only once in this process, please! // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, // it's actually doing a lot of work. IPEndPoint endPoint = finalDestination.ExternalEndPoint; if (endPoint.Address != null) { sp.ControllingClient.SendTeleportProgress(teleportFlags, "arriving"); if (m_cancelingAgents.Contains(sp.UUID)) { Cancel(sp); return; } // Fixing a bug where teleporting while sitting results in the avatar ending up removed from // both regions if (sp.ParentID != UUID.Zero) sp.StandUp(); if (!sp.ValidateAttachments()) { sp.ControllingClient.SendTeleportProgress(teleportFlags, "missing_attach_tport"); sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); return; } string capsPath = String.Empty; AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); agentCircuit.startpos = position; agentCircuit.child = true; agentCircuit.Appearance = sp.Appearance; if (currentAgentCircuit != null) { agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs; agentCircuit.IPAddress = currentAgentCircuit.IPAddress; agentCircuit.Viewer = currentAgentCircuit.Viewer; agentCircuit.Channel = currentAgentCircuit.Channel; agentCircuit.Mac = currentAgentCircuit.Mac; agentCircuit.Id0 = currentAgentCircuit.Id0; } if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) { // brand new agent, let's create a new caps seed agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); } string reason = String.Empty; // Let's create an agent there if one doesn't exist yet. bool logout = false; if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) { sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", reason)); return; } // OK, it got this agent. Let's close some child agents sp.CloseChildAgents(newRegionX, newRegionY); if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) { //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); #region IP Translation for NAT IClientIPEndpoint ipepClient; if (sp.ClientView.TryGet(out ipepClient)) { capsPath = "http://" + NetworkUtil.GetHostFor(ipepClient.EndPoint, finalDestination.ExternalHostName) + ":" + finalDestination.HttpPort + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); } else { capsPath = "http://" + finalDestination.ExternalHostName + ":" + finalDestination.HttpPort + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); } #endregion if (eq != null) { #region IP Translation for NAT // Uses ipepClient above if (sp.ClientView.TryGet(out ipepClient)) { endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); } #endregion eq.EnableSimulator(destinationHandle, endPoint, sp.UUID); // ES makes the client send a UseCircuitCode message to the destination, // which triggers a bunch of things there. // So let's wait Thread.Sleep(200); eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); } else { sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); } } else { agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); capsPath = "http://" + finalDestination.ExternalHostName + ":" + finalDestination.HttpPort + "/CAPS/" + agentCircuit.CapsPath + "0000/"; } if (m_cancelingAgents.Contains(sp.UUID)) { Cancel(sp); return; } SetInTransit(sp.UUID); // Let's send a full update of the agent. This is a synchronous call. AgentData agent = new AgentData(); sp.CopyTo(agent); agent.Position = position; SetCallbackURL(agent, sp.Scene.RegionInfo); //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Updating agent..."); if (!UpdateAgent(reg, finalDestination, agent)) { // Region doesn't take it Fail(sp, finalDestination); return; } m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID); if (eq != null) { eq.TeleportFinishEvent(destinationHandle, 13, endPoint, 0, teleportFlags, capsPath, sp.UUID, teleportFlags); } else { sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, teleportFlags, capsPath); } // Let's set this to true tentatively. This does not trigger OnChildAgent sp.IsChildAgent = true; // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation // that the client contacted the destination before we send the attachments and close things here. //OpenSim sucks at callbacks, disable it for now if (!WaitForCallback(sp.UUID)) { /*//Make sure the client hasn't TPed back in this time. ScenePresence SP = m_aScene.GetScenePresence(sp.UUID); if (SP != null && SP.IsChildAgent) { //Disabling until this actually helps and doesn't kill clients //Fail(sp, finalDestination); return; } else if (SP == null) { //Err.. this happens somehow. return; }*/ } /*//Make sure the client hasn't TPed back in this time. ScenePresence newSP = m_aScene.GetScenePresence(sp.UUID); if (newSP != null && !newSP.IsChildAgent) { //They are root again, don't cross them! return; } else if (newSP == null) { //Err.. this happens somehow. return; }*/ // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it CrossAttachmentsIntoNewRegion(finalDestination, sp, true); // Well, this is it. The agent is over there. KillEntity(sp.Scene, sp.LocalId); // May need to logout or other cleanup AgentHasMovedAway(sp.ControllingClient.SessionId, logout); // Now let's make it officially a child agent sp.MakeChildAgent(); // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) { Thread.Sleep(5000); sp.Close(); sp.Scene.IncomingCloseAgent(sp.UUID); } else // now we have a child agent in this region. sp.Reset(); //If they canceled too late, remove them so the next tp does not fail. if (m_cancelingAgents.Contains(sp.UUID)) m_cancelingAgents.Remove(sp.UUID); } else { sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); } }
public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData) { int childAgentUpdateStart = Environment.TickCount; try { // Try local first if (m_localBackend.SendChildAgentUpdate(regionHandle, cAgentData)) return true; // else do the remote thing if (!m_localBackend.IsLocalRegion(regionHandle)) { RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); if (regInfo != null) { return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); } //else // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); } return false; } finally { m_log.DebugFormat("[REST COMM] SendCreateChildAgent: {0} ms", Environment.TickCount - childAgentUpdateStart); } }
public void UpdateChildAgent(AgentData cAgentData) { // m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName); if (!IsChildAgent) return; CopyFrom(cAgentData); }
private void CopyFrom(AgentData cAgent) { m_callbackURI = cAgent.CallbackURI; // m_log.DebugFormat( // "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()", // Name, m_scene.RegionInfo.RegionName, m_callbackURI); m_pos = cAgent.Position; m_velocity = cAgent.Velocity; CameraPosition = cAgent.Center; CameraAtAxis = cAgent.AtAxis; CameraLeftAxis = cAgent.LeftAxis; CameraUpAxis = cAgent.UpAxis; ParentUUID = cAgent.ParentPart; PrevSitOffset = cAgent.SitOffset; // When we get to the point of re-computing neighbors everytime this // changes, then start using the agent's drawdistance rather than the // region's draw distance. DrawDistance = cAgent.Far; //DrawDistance = Scene.DefaultDrawDistance; if (cAgent.ChildrenCapSeeds != null && cAgent.ChildrenCapSeeds.Count > 0) { if (Scene.CapsModule != null) { Scene.CapsModule.SetChildrenSeed(UUID, cAgent.ChildrenCapSeeds); } KnownRegions = cAgent.ChildrenCapSeeds; } if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) ControllingClient.SetChildAgentThrottle(cAgent.Throttles); m_headrotation = cAgent.HeadRotation; Rotation = cAgent.BodyRotation; m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) GodLevel = cAgent.GodLevel; SetAlwaysRun = cAgent.AlwaysRun; Appearance = new AvatarAppearance(cAgent.Appearance); /* bool isFlying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); if (PhysicsActor != null) { RemoveFromPhysicalScene(); AddToPhysicalScene(isFlying); } */ try { lock (scriptedcontrols) { if (cAgent.Controllers != null) { scriptedcontrols.Clear(); foreach (ControllerData c in cAgent.Controllers) { ScriptControllers sc = new ScriptControllers(); sc.objectID = c.ObjectID; sc.itemID = c.ItemID; sc.ignoreControls = (ScriptControlled)c.IgnoreControls; sc.eventControls = (ScriptControlled)c.EventControls; scriptedcontrols[sc.itemID] = sc; } } } } catch { } Animator.ResetAnimations(); Overrides.CopyAOPairsFrom(cAgent.MovementAnimationOverRides); // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? if (cAgent.DefaultAnim != null) Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); if (cAgent.AnimState != null) Animator.Animations.SetImplicitDefaultAnimation(cAgent.AnimState.AnimID, cAgent.AnimState.SequenceNum, UUID.Zero); if (cAgent.Anims != null) Animator.Animations.FromArray(cAgent.Anims); if (cAgent.MotionState != 0) Animator.currentControlState = (ScenePresenceAnimator.motionControlStates) cAgent.MotionState; if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.CopyAttachments(cAgent, this); lock (m_originRegionIDAccessLock) m_originRegionID = cAgent.RegionID; }
public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData) { foreach (Scene s in m_sceneList) { if (s.RegionInfo.RegionHandle == regionHandle) { //m_log.DebugFormat( // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", // s.RegionInfo.RegionName, regionHandle); s.IncomingChildAgentDataUpdate(cAgentData); return true; } } // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); return false; }
public ChildAgentUpdate2Response SendChildAgentUpdate2(SimpleRegionInfo regionInfo, AgentData data) { foreach (Scene s in m_sceneList) { if (s.RegionInfo.RegionHandle == regionInfo.RegionHandle) { return s.IncomingChildAgentDataUpdate2(data); } } return ChildAgentUpdate2Response.Error; }
protected void DoAgentPut(Hashtable request, Hashtable responsedata) { 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; if (args.ContainsKey("destination_x") && args["destination_x"] != null) Int32.TryParse(args["destination_x"].AsString(), out x); if (args.ContainsKey("destination_y") && args["destination_y"] != null) Int32.TryParse(args["destination_y"].AsString(), out 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; string messageType; if (args["message_type"] != null) messageType = args["message_type"].AsString(); else { m_log.Warn("[AGENT HANDLER]: Agent Put Message Type not found. "); messageType = "AgentData"; } bool result = true; if ("AgentData".Equals(messageType)) { AgentData agent = new AgentData(); try { agent.Unpack(args, m_SimulationService.GetScene(destination.RegionHandle)); } catch (Exception ex) { m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); responsedata["int_response_code"] = HttpStatusCode.BadRequest; responsedata["str_response_string"] = "Bad request"; return; } //agent.Dump(); // This is one of the meanings of PUT agent result = UpdateAgent(destination, agent); } else if ("AgentPosition".Equals(messageType)) { AgentPosition agent = new AgentPosition(); try { agent.Unpack(args, m_SimulationService.GetScene(destination.RegionHandle)); } catch (Exception ex) { m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); return; } //agent.Dump(); // This is one of the meanings of PUT agent result = m_SimulationService.UpdateAgent(destination, agent); } responsedata["int_response_code"] = HttpStatusCode.OK; responsedata["str_response_string"] = result.ToString(); //responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead }
// subclasses can override this protected virtual bool UpdateAgent(GridRegion destination, AgentData agent) { return m_SimulationService.UpdateAgent(destination, agent); }
/// <summary> /// This Closes child agents on neighboring regions /// Calls an asynchronous method to do so.. so it doesn't lag the sim. /// </summary> protected ScenePresence CrossAgentSittingToNewRegionAsync(ScenePresence agent, GridRegion neighbourRegion, SceneObjectGroup grp) { Scene m_scene = agent.Scene; if (agent.ValidateAttachments()) { AgentData cAgent = new AgentData(); agent.CopyTo(cAgent); cAgent.Position = grp.AbsolutePosition; cAgent.CallbackURI = "http://" + m_scene.RegionInfo.ExternalHostName + ":" + m_scene.RegionInfo.HttpPort + "/agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/"; if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) { // region doesn't take it ResetFromTransit(agent.UUID); return agent; } // Next, let's close the child agent connections that are too far away. agent.CloseChildAgents((uint)neighbourRegion.RegionLocX / 256, (uint)neighbourRegion.RegionLocY / 256); string agentcaps; if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) { m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", neighbourRegion.RegionHandle); return agent; } // TODO Should construct this behind a method string capsPath = "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/"; m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>(); if (eq != null) { eq.CrossRegion(neighbourRegion.RegionHandle, agent.AbsolutePosition, agent.Velocity, neighbourRegion.ExternalEndPoint, capsPath, agent.UUID, agent.ControllingClient.SessionId); } else { agent.ControllingClient.CrossRegion(neighbourRegion.RegionHandle, agent.AbsolutePosition, agent.Velocity, neighbourRegion.ExternalEndPoint, capsPath); } agent.MakeChildAgent(); // now we have a child agent in this region. Request all interesting data about other (root) agents agent.SendInitialFullUpdateToAllClients(); CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); } return agent; }
/// <summary> /// This Closes child agents on neighboring regions /// Calls an asynchronous method to do so.. so it doesn't lag the sim. /// </summary> protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying) { m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); Scene m_scene = agent.Scene; ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); if (neighbourRegion != null && agent.ValidateAttachments()) { pos = pos + (agent.Velocity); SetInTransit(agent.UUID); AgentData cAgent = new AgentData(); agent.CopyTo(cAgent); cAgent.Position = pos; if (isFlying) cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; cAgent.CallbackURI = "http://" + m_scene.RegionInfo.ExternalHostName + ":" + m_scene.RegionInfo.HttpPort + "/agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/"; if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) { // region doesn't take it ResetFromTransit(agent.UUID); return agent; } agent.ControllingClient.RequestClientInfo(); string agentcaps; if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) { m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", neighbourRegion.RegionHandle); return agent; } // TODO Should construct this behind a method string capsPath = "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/"; m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>(); if (eq != null) { eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, capsPath, agent.UUID, agent.ControllingClient.SessionId); } else { agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, capsPath); } if (!WaitForCallback(agent.UUID)) { m_log.Debug("[ENTITY TRANSFER MODULE]: Callback never came in crossing agent"); ResetFromTransit(agent.UUID); // Yikes! We should just have a ref to scene here. //agent.Scene.InformClientOfNeighbours(agent); EnableChildAgents(agent); return agent; } // Next, let's close the child agent connections that are too far away. agent.CloseChildAgents(neighbourx, neighboury); agent.MakeChildAgent(); // now we have a child agent in this region. Request all interesting data about other (root) agents agent.SendInitialFullUpdateToAllClients(); CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); } //m_log.Debug("AFTER CROSS"); //Scene.DumpChildrenSeeds(UUID); //DumpKnownRegions(); return agent; }
protected virtual void SetCallbackURL(AgentData agent, RegionInfo region) { agent.CallbackURI = "http://" + region.ExternalHostName + ":" + region.HttpPort + "/agent/" + agent.AgentID.ToString() + "/" + region.RegionID.ToString() + "/release/"; }
/// <summary> /// We've got an update about an agent that sees into this region, /// send it to ScenePresence for processing It's the full data. /// </summary> /// <param name="cAgentData">Agent that contains all of the relevant things about an agent. /// Appearance, animations, position, etc.</param> /// <returns>true if we handled it.</returns> public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) { m_log.DebugFormat( "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); // XPTO: if this agent is not allowed here as root, always return false // TODO: This check should probably be in QueryAccess(). ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); if (nearestParcel == null) { m_log.DebugFormat( "[SCENE]: Denying root agent entry to {0} in {1}: no allowed parcel", cAgentData.AgentID, RegionInfo.RegionName); return false; } // We have to wait until the viewer contacts this region // after receiving the EnableSimulator HTTP Event Queue message. This triggers the viewer to send // a UseCircuitCode packet which in turn calls AddNewClient which finally creates the ScenePresence. ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); if (childAgentUpdate != null) { childAgentUpdate.ChildAgentDataUpdate(cAgentData); return true; } return false; }
public void CopyTo(AgentData cAgent) { cAgent.CallbackURI = m_callbackURI; cAgent.AgentID = UUID; cAgent.RegionID = Scene.RegionInfo.RegionID; cAgent.Position = AbsolutePosition; cAgent.Velocity = m_velocity; cAgent.Center = CameraPosition; cAgent.AtAxis = CameraAtAxis; cAgent.LeftAxis = CameraLeftAxis; cAgent.UpAxis = CameraUpAxis; cAgent.Far = DrawDistance; // Throttles float multiplier = 1; int childRegions = KnownRegionCount; if (childRegions != 0) multiplier = 1f / childRegions; // Minimum throttle for a child region is 1/4 of the root region throttle if (multiplier <= 0.25f) multiplier = 0.25f; cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); cAgent.HeadRotation = m_headrotation; cAgent.BodyRotation = Rotation; cAgent.ControlFlags = (uint)m_AgentControlFlags; if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) cAgent.GodLevel = (byte)GodLevel; else cAgent.GodLevel = (byte) 0; cAgent.AlwaysRun = SetAlwaysRun; cAgent.Appearance = new AvatarAppearance(Appearance); lock (scriptedcontrols) { ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; int i = 0; foreach (ScriptControllers c in scriptedcontrols.Values) { controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); } cAgent.Controllers = controls; } // Animations try { cAgent.Anims = Animator.Animations.ToArray(); } catch { } if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.CopyAttachments(this, cAgent); }
/// <summary> /// Send complete data about an agent in this region to a neighbor /// </summary> public bool UpdateAgent(GridRegion destination, AgentData data) { return UpdateAgent(destination, (IAgentData)data, 200000); // yes, 200 seconds }
protected virtual bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent) { return m_aScene.SimulationService.UpdateAgent(finalDestination, agent); }
public void CopyTo(AgentData cAgent) { cAgent.CallbackURI = m_callbackURI; cAgent.AgentID = UUID; cAgent.RegionID = Scene.RegionInfo.RegionID; cAgent.SessionID = ControllingClient.SessionId; cAgent.Position = AbsolutePosition; cAgent.Velocity = m_velocity; cAgent.Center = CameraPosition; cAgent.AtAxis = CameraAtAxis; cAgent.LeftAxis = CameraLeftAxis; cAgent.UpAxis = CameraUpAxis; cAgent.Far = DrawDistance; // Throttles cAgent.Throttles = ControllingClient.GetThrottlesPacked(1); cAgent.HeadRotation = m_headrotation; cAgent.BodyRotation = Rotation; cAgent.ControlFlags = (uint)m_AgentControlFlags; if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) cAgent.GodLevel = (byte)GodLevel; else cAgent.GodLevel = (byte) 0; cAgent.AlwaysRun = SetAlwaysRun; // make clear we want the all thing cAgent.Appearance = new AvatarAppearance(Appearance,true,true); cAgent.ParentPart = ParentUUID; cAgent.SitOffset = PrevSitOffset; lock (scriptedcontrols) { ControllerData[] controls = new ControllerData[scriptedcontrols.Count]; int i = 0; foreach (ScriptControllers c in scriptedcontrols.Values) { controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); } cAgent.Controllers = controls; } // Animations try { cAgent.Anims = Animator.Animations.ToArray(); } catch { } cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; cAgent.AnimState = Animator.Animations.ImplicitDefaultAnimation; cAgent.MovementAnimationOverRides = Overrides.CloneAOPairs(); cAgent.MotionState = (byte)Animator.currentControlState; if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.CopyAttachments(this, cAgent); }
/// <summary> /// This Closes child agents on neighbouring regions /// Calls an asynchronous method to do so.. so it doesn't lag the sim. /// </summary> protected ScenePresence CrossAgentToNewRegionAsync( ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, GridRegion neighbourRegion, bool isFlying, string version) { try { ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3} running version {4}", agent.Firstname, agent.Lastname, neighbourx, neighboury, version); Scene m_scene = agent.Scene; if (neighbourRegion != null) { if (!agent.ValidateAttachments()) m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for region crossing of {0} from {1} to {2}. Continuing.", agent.Name, agent.Scene.RegionInfo.RegionName, neighbourRegion.RegionName); pos = pos + agent.Velocity; Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0); agent.RemoveFromPhysicalScene(); SetInTransit(agent.UUID); AgentData cAgent = new AgentData(); agent.CopyTo(cAgent); cAgent.Position = pos; if (isFlying) cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; // We don't need the callback anymnore cAgent.CallbackURI = String.Empty; if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) { // region doesn't take it ReInstantiateScripts(agent); agent.AddToPhysicalScene(isFlying); ResetFromTransit(agent.UUID); return agent; } //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); agent.ControllingClient.RequestClientInfo(); //m_log.Debug("BEFORE CROSS"); //Scene.DumpChildrenSeeds(UUID); //DumpKnownRegions(); string agentcaps; if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) { m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", neighbourRegion.RegionHandle); return agent; } string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps); m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>(); if (eq != null) { eq.CrossRegion(neighbourHandle, pos, vel2 /* agent.Velocity */, neighbourRegion.ExternalEndPoint, capsPath, agent.UUID, agent.ControllingClient.SessionId); } else { agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, capsPath); } // SUCCESS! agent.MakeChildAgent(); ResetFromTransit(agent.UUID); // now we have a child agent in this region. Request all interesting data about other (root) agents agent.SendOtherAgentsAvatarDataToMe(); agent.SendOtherAgentsAppearanceToMe(); // Backwards compatibility. Best effort if (version == "Unknown" || version == string.Empty) { m_log.DebugFormat("[ENTITY TRANSFER MODULE]: neighbor with old version, passing attachments one by one..."); Thread.Sleep(3000); // wait a little now that we're not waiting for the callback CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); } // Next, let's close the child agent connections that are too far away. agent.CloseChildAgents(neighbourx, neighboury); AgentHasMovedAway(agent, false); // the user may change their profile information in other region, // so the userinfo in UserProfileCache is not reliable any more, delete it // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! if (agent.Scene.NeedSceneCacheClear(agent.UUID)) { m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID); } } //m_log.Debug("AFTER CROSS"); //Scene.DumpChildrenSeeds(UUID); //DumpKnownRegions(); } catch (Exception e) { m_log.ErrorFormat( "[ENTITY TRANSFER MODULE]: Problem crossing user {0} to new region {1} from {2}. Exception {3}{4}", agent.Name, neighbourRegion.RegionName, agent.Scene.RegionInfo.RegionName, e.Message, e.StackTrace); } return agent; }
private void CopyFrom(AgentData cAgent) { m_originRegionID = cAgent.RegionID; m_callbackURI = cAgent.CallbackURI; // m_log.DebugFormat( // "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()", // Name, m_scene.RegionInfo.RegionName, m_callbackURI); m_pos = cAgent.Position; m_velocity = cAgent.Velocity; CameraPosition = cAgent.Center; CameraAtAxis = cAgent.AtAxis; CameraLeftAxis = cAgent.LeftAxis; CameraUpAxis = cAgent.UpAxis; // When we get to the point of re-computing neighbors everytime this // changes, then start using the agent's drawdistance rather than the // region's draw distance. // DrawDistance = cAgent.Far; DrawDistance = Scene.DefaultDrawDistance; if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) ControllingClient.SetChildAgentThrottle(cAgent.Throttles); m_headrotation = cAgent.HeadRotation; Rotation = cAgent.BodyRotation; m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) GodLevel = cAgent.GodLevel; SetAlwaysRun = cAgent.AlwaysRun; Appearance = new AvatarAppearance(cAgent.Appearance); if (PhysicsActor != null) { bool isFlying = Flying; RemoveFromPhysicalScene(); AddToPhysicalScene(isFlying); } try { lock (scriptedcontrols) { if (cAgent.Controllers != null) { scriptedcontrols.Clear(); foreach (ControllerData c in cAgent.Controllers) { ScriptControllers sc = new ScriptControllers(); sc.itemID = c.ItemID; sc.ignoreControls = (ScriptControlled)c.IgnoreControls; sc.eventControls = (ScriptControlled)c.EventControls; scriptedcontrols[sc.itemID] = sc; } } } } catch { } // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? if (cAgent.Anims != null) Animator.Animations.FromArray(cAgent.Anims); if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.CopyAttachments(cAgent, this); }
public static OSD EnableChildAgents(int DrawDistance, GridRegion[] neighbors, AgentCircuitData circuit, uint TeleportFlags, AgentData data, byte[] IPAddress, int Port) { OSDMap llsdBody = new OSDMap(); llsdBody.Add("DrawDistance", DrawDistance); OSDArray regionsArray = new OSDArray(); foreach (GridRegion r in neighbors) { regionsArray.Add(r.ToOSD()); } llsdBody.Add("Regions", regionsArray); if(IPAddress != null) llsdBody.Add("IPAddress", IPAddress); if(Port != 0) //0 is the eqivilent of null llsdBody.Add("Port", Port); llsdBody.Add("Circuit", circuit.PackAgentCircuitData()); llsdBody.Add("TeleportFlags", TeleportFlags); if(data != null) llsdBody.Add("AgentData", data.Pack()); return buildEvent("EnableChildAgents", llsdBody); }
protected virtual void SetCallbackURL(AgentData agent, RegionInfo region) { agent.CallbackURI = region.ServerURI + "agent/" + agent.AgentID.ToString() + "/" + region.RegionID.ToString() + "/release/"; m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Set callback URL to {0}", agent.CallbackURI); }
public bool UpdateAgent(GridRegion destination, AgentData cAgentData) { if (destination == null) return false; // Try local first if (m_localBackend.IsLocalRegion(destination.RegionID)) return m_localBackend.UpdateAgent(destination, cAgentData); return m_remoteConnector.UpdateAgent(destination, cAgentData); }
public ChildAgentUpdate2Response SendChildAgentUpdate2(SimpleRegionInfo regionInfo, AgentData data) { int childAgentUpdateStart = Environment.TickCount; try { // Try local first if (m_localBackend.SendChildAgentUpdate2(regionInfo, data) == ChildAgentUpdate2Response.Ok) return ChildAgentUpdate2Response.Ok; // else do the remote thing if (!m_localBackend.IsLocalRegion(regionInfo.RegionHandle)) { RegionClient.AgentUpdate2Ret ret = m_regionClient.DoChildAgentUpdateCall2(regionInfo, data); switch (ret) { case RegionClient.AgentUpdate2Ret.Ok: return ChildAgentUpdate2Response.Ok; case RegionClient.AgentUpdate2Ret.Error: return ChildAgentUpdate2Response.Error; case RegionClient.AgentUpdate2Ret.NotFound: return ChildAgentUpdate2Response.MethodNotAvailalble; case RegionClient.AgentUpdate2Ret.AccessDenied: return ChildAgentUpdate2Response.AccessDenied; } } return ChildAgentUpdate2Response.Error; } finally { m_log.DebugFormat("[REST COMM] SendChildAgentUpdateCall2: {0} ms", Environment.TickCount - childAgentUpdateStart); } }
public void CopyAttachments(IScenePresence sp, AgentData ad) { lock (sp.AttachmentsSyncLock) { // Attachment objects List<SceneObjectGroup> attachments = sp.GetAttachments(); if (attachments.Count > 0) { ad.AttachmentObjects = new List<ISceneObject>(); ad.AttachmentObjectStates = new List<string>(); // IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>(); sp.InTransitScriptStates.Clear(); foreach (SceneObjectGroup sog in attachments) { // We need to make a copy and pass that copy // because of transfers withn the same sim ISceneObject clone = sog.CloneForNewScene(); // Attachment module assumes that GroupPosition holds the offsets...! ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; ((SceneObjectGroup)clone).IsAttachment = false; ad.AttachmentObjects.Add(clone); string state = sog.GetStateSnapshot(); ad.AttachmentObjectStates.Add(state); sp.InTransitScriptStates.Add(state); // Scripts of the originals will be removed when the Agent is successfully removed. // sog.RemoveScriptInstances(true); } } } }
protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata) { 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.ContainsKey("destination_handle")) UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); string messageType; if (args.ContainsKey("message_type")) messageType = args["message_type"].AsString(); else { m_log.Warn("[REST COMMS]: Agent Put Message Type not found. "); messageType = "AgentData"; } bool result = true; if ("AgentData".Equals(messageType)) { AgentData agent = new AgentData(); try { agent.Unpack(args); } catch (Exception ex) { m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); return; } //agent.Dump(); // This is one of the meanings of PUT agent result = m_localBackend.SendChildAgentUpdate(regionhandle, agent); } else if ("AgentPosition".Equals(messageType)) { AgentPosition agent = new AgentPosition(); try { agent.Unpack(args); } catch (Exception ex) { m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); return; } //agent.Dump(); // This is one of the meanings of PUT agent result = m_localBackend.SendChildAgentUpdate(regionhandle, agent); } responsedata["int_response_code"] = 200; responsedata["str_response_string"] = result.ToString(); }
public void CopyAttachments(AgentData ad, IScenePresence sp) { if (ad.AttachmentObjects != null && ad.AttachmentObjects.Count > 0) { lock (sp.AttachmentsSyncLock) sp.ClearAttachments(); int i = 0; foreach (ISceneObject so in ad.AttachmentObjects) { ((SceneObjectGroup)so).LocalId = 0; ((SceneObjectGroup)so).RootPart.ClearUpdateSchedule(); so.SetState(ad.AttachmentObjectStates[i++], m_scene); m_scene.IncomingCreateObject(Vector3.Zero, so); } } }