コード例 #1
0
        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.RegionID));
                }
                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.RegionID));
                }
                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
        }
コード例 #2
0
        protected virtual 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)
                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(null, x, y);
                    if (requestingGridRegion != null)
                        Util.FireAndForget((o) => EnableChildAgentsForRegion(requestingGridRegion));
                }
            }
            else if (message["Method"] == "DisableSimulator")
            {
                //KILL IT!
                if (regionCaps == null || clientCaps == null)
                    return null;
                IEventQueueService eventQueue = m_registry.RequestModuleInterface<IEventQueueService>();
                eventQueue.DisableSimulator(regionCaps.AgentID, regionCaps.RegionHandle);
                //regionCaps.Close();
                //clientCaps.RemoveCAPS(requestingRegion);
                regionCaps.Disabled = true;
            }
            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, false); //The root is killing itself
                    }
                }
            }
            else if (message["Method"] == "SendChildAgentUpdate")
            {
                if (regionCaps == null || clientCaps == null)
                    return null;
                IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService();
                if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle) //Has to be root
                {
                    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;
                    string ResponseURL = message["ResponseURL"].AsString();
                    if (ResponseURL == "")
                    {
                        OSDMap result = new OSDMap();
                        string reason = "";
                        result["success"] = TeleportAgent(ref destination, TeleportFlags, DrawDistance,
                                                          Circuit, AgentData, AgentID, requestingRegion, out reason);
                        result["Reason"] = reason;
                        //Remove the region flags, not the regions problem
                        destination.Flags = 0;
                        result["Destination"] = destination.ToOSD(); //Send back the new destination
                        return result;
                    }
                    else
                    {
                        Util.FireAndForget(delegate
                        {
                            OSDMap result = new OSDMap();
                            string reason = "";
                            result["success"] = TeleportAgent(ref destination, TeleportFlags, DrawDistance,
                                                              Circuit, AgentData, AgentID, requestingRegion, out reason);
                            result["Reason"] = reason;
                            //Remove the region flags, not the regions problem
                            destination.Flags = 0;
                            result["Destination"] = destination.ToOSD(); //Send back the new destination
                            WebUtils.PostToService(ResponseURL, result);
                        });
                        return new OSDMap() { new KeyValuePair<string, OSD>("WillHaveResponse", true) };
                    }
                }
            }
            else if (message["Method"] == "CrossAgent")
            {
                if (regionCaps == null || clientCaps == null)
                    return null;
                IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService();
                if (rootCaps == null || rootCaps.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;

                    string ResponseURL = message["ResponseURL"].AsString();
                    if (ResponseURL == "")
                    {
                        OSDMap result = new OSDMap();
                        string reason = "";
                        result["success"] = CrossAgent(Region, pos, Vel, Circuit, AgentData,
                                                       AgentID, requestingRegion, out reason);
                        result["reason"] = reason;
                        return result;
                    }
                    else
                    {
                        Util.FireAndForget(delegate
                        {
                            OSDMap result = new OSDMap();
                            string reason = "";
                            result["success"] = CrossAgent(Region, pos, Vel, Circuit, AgentData,
                                                           AgentID, requestingRegion, out reason);
                            result["reason"] = reason;
                            if (ResponseURL != null)
                                WebUtils.PostToService(ResponseURL, result);
                        });
                        return new OSDMap() { new KeyValuePair<string, OSD>("WillHaveResponse", true) };
                    }
                }
                else if (clientCaps.InTeleport)
                {
                    OSDMap result = new OSDMap();
                    result["success"] = false;
                    result["Note"] = false;
                    return result;
                }
                else
                {
                    OSDMap result = new OSDMap();
                    result["success"] = false;
                    result["Note"] = false;
                    return result;
                }
            }
            return null;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        protected void DoAgentPut(OSDMap args, IOSHttpResponse httpResponse)
        {
            // retrieve the input arguments
            OSD tmpOSD;
            EntityTransferContext ctx = new EntityTransferContext();
            int    x = 0, y = 0;
            UUID   uuid = UUID.Zero;
            string regionname = string.Empty;

            if (args.TryGetValue("destination_x", out tmpOSD) && tmpOSD != null)
            {
                Int32.TryParse(tmpOSD.AsString(), out x);
            }
            if (args.TryGetValue("destination_y", out tmpOSD) && tmpOSD != null)
            {
                Int32.TryParse(tmpOSD.AsString(), out y);
            }
            if (args.TryGetValue("destination_uuid", out tmpOSD) && tmpOSD != null)
            {
                UUID.TryParse(tmpOSD.AsString(), out uuid);
            }
            if (args.TryGetValue("destination_name", out tmpOSD) && tmpOSD != null)
            {
                regionname = tmpOSD.ToString();
            }
            if (args.TryGetValue("context", out tmpOSD) && tmpOSD is OSDMap)
            {
                ctx.Unpack((OSDMap)tmpOSD);
            }

            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.RegionID), ctx);
                }
                catch (Exception ex)
                {
                    m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
                    httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
                    httpResponse.RawBuffer  = Util.UTF8.GetBytes("false");
                    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.RegionID), ctx);
                }
                catch (Exception ex)
                {
                    m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
                    httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
                    httpResponse.RawBuffer  = Util.UTF8.GetBytes("false");
                    return;
                }
                //agent.Dump();
                // This is one of the meanings of PUT agent
                result = m_SimulationService.UpdateAgent(destination, agent);
            }

            httpResponse.StatusCode = (int)HttpStatusCode.OK;
            httpResponse.RawBuffer  = Util.UTF8.GetBytes(result.ToString());
            //responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead
        }
コード例 #5
0
ファイル: AgentHandlers.cs プロジェクト: JAllard/Aurora-Sim
        protected void DoAgentPut(Hashtable request, Hashtable responsedata)
        {
            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;
            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
                                         {RegionID = uuid, RegionLocX = x, RegionLocY = y, RegionName = regionname};

            string messageType;
            if (args["message_type"] != null)
                messageType = args["message_type"].AsString();
            else
            {
                MainConsole.Instance.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);
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex);
                    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);
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex);
                    return;
                }
                //agent.Dump();
                // This is one of the meanings of PUT agent
                result = m_SimulationService.UpdateAgent(destination, agent);
            }
            OSDMap resp = new OSDMap();
            resp["Updated"] = result;
            responsedata["int_response_code"] = HttpStatusCode.OK;
            responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
        }
コード例 #6
0
        public void AgentPositionTest01()
        {
            UUID    AgentId1     = UUID.Random();
            UUID    SessionId1   = UUID.Random();
            uint    CircuitCode1 = uint.MinValue;
            Vector3 Size1        = Vector3.UnitZ;
            Vector3 Position1    = Vector3.UnitX;
            Vector3 LeftAxis1    = Vector3.UnitY;
            Vector3 UpAxis1      = Vector3.UnitZ;
            Vector3 AtAxis1      = Vector3.UnitX;

            ulong RegionHandle1 = ulong.MinValue;

            byte[] Throttles1 = new byte[] { 0, 1, 0 };

            Vector3 Velocity1 = Vector3.Zero;
            float   Far1      = 256;

            bool    ChangedGrid1 = false;
            Vector3 Center1      = Vector3.Zero;

            AgentPosition position1 = new AgentPosition();

            position1.AgentID      = AgentId1;
            position1.SessionID    = SessionId1;
            position1.CircuitCode  = CircuitCode1;
            position1.Size         = Size1;
            position1.Position     = Position1;
            position1.LeftAxis     = LeftAxis1;
            position1.UpAxis       = UpAxis1;
            position1.AtAxis       = AtAxis1;
            position1.RegionHandle = RegionHandle1;
            position1.Throttles    = Throttles1;
            position1.Velocity     = Velocity1;
            position1.Far          = Far1;
            position1.ChangedGrid  = ChangedGrid1;
            position1.Center       = Center1;

            ChildAgentDataUpdate cadu = new ChildAgentDataUpdate();

            cadu.AgentID        = AgentId1.Guid;
            cadu.ActiveGroupID  = UUID.Zero.Guid;
            cadu.throttles      = Throttles1;
            cadu.drawdistance   = Far1;
            cadu.Position       = Position1;
            cadu.Velocity       = Velocity1;
            cadu.regionHandle   = RegionHandle1;
            cadu.cameraPosition = Center1;
            cadu.AVHeight       = Size1.Z;

            AgentPosition position2 = new AgentPosition();

            position2.CopyFrom(cadu);

            Assert.IsTrue(
                position2.AgentID == position1.AgentID &&
                position2.Size == position1.Size &&
                position2.Position == position1.Position &&
                position2.Velocity == position1.Velocity &&
                position2.Center == position1.Center &&
                position2.RegionHandle == position1.RegionHandle &&
                position2.Far == position1.Far

                , "Copy From ChildAgentDataUpdate failed");

            position2 = new AgentPosition();

            Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition");
            position2.Unpack(position1.Pack(), null);

            Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed");
            Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed");
            Assert.IsTrue(position2.Velocity == position1.Velocity, "Velocity didn't unpack the same way it packed");
            Assert.IsTrue(position2.SessionID == position1.SessionID, "SessionID didn't unpack the same way it packed");
            Assert.IsTrue(position2.CircuitCode == position1.CircuitCode, "CircuitCode didn't unpack the same way it packed");
            Assert.IsTrue(position2.LeftAxis == position1.LeftAxis, "LeftAxis didn't unpack the same way it packed");
            Assert.IsTrue(position2.UpAxis == position1.UpAxis, "UpAxis didn't unpack the same way it packed");
            Assert.IsTrue(position2.AtAxis == position1.AtAxis, "AtAxis didn't unpack the same way it packed");
            Assert.IsTrue(position2.RegionHandle == position1.RegionHandle, "RegionHandle didn't unpack the same way it packed");
            Assert.IsTrue(position2.ChangedGrid == position1.ChangedGrid, "ChangedGrid didn't unpack the same way it packed");
            Assert.IsTrue(position2.Center == position1.Center, "Center didn't unpack the same way it packed");
            Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed");
        }
コード例 #7
0
        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["destination_handle"] != null)
            {
                UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
            }

            string messageType;

            if (args["message_type"] != null)
            {
                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();
        }