当前位置: 首页>>代码示例>>C#>>正文


C# AgentCircuitData.UnpackAgentCircuitData方法代码示例

本文整理汇总了C#中AgentCircuitData.UnpackAgentCircuitData方法的典型用法代码示例。如果您正苦于以下问题:C# AgentCircuitData.UnpackAgentCircuitData方法的具体用法?C# AgentCircuitData.UnpackAgentCircuitData怎么用?C# AgentCircuitData.UnpackAgentCircuitData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AgentCircuitData的用法示例。


在下文中一共展示了AgentCircuitData.UnpackAgentCircuitData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoAgentPost

        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);
        }
开发者ID:EnricoNirvana,项目名称:Aurora-HG-Plugin,代码行数:66,代码来源:AgentHandlers.cs

示例2: TestAgentCircuitDataOSDConversion

       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]));
           */


        }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:58,代码来源:AgentCircuitDataTest.cs

示例3: Enqueue

        /// <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);
//.........这里部分代码省略.........
开发者ID:KristenMynx,项目名称:Aurora-Sim,代码行数:101,代码来源:EventQueueService.cs

示例4: HistoricalAgentCircuitDataOSDConversion

        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]));
            */
       }
开发者ID:BackupTheBerlios,项目名称:seleon,代码行数:53,代码来源:AgentCircuitDataTest.cs

示例5: Enqueue

        /// <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"]);
//.........这里部分代码省略.........
开发者ID:mugginsm,项目名称:Aurora-Sim,代码行数:101,代码来源:EventQueueService.cs


注:本文中的AgentCircuitData.UnpackAgentCircuitData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。