Serialize() public method

Serialize the object
public Serialize ( ) : OSDMap
return OSDMap
        public void EnableSimulatorMessage()
        {
            EnableSimulatorMessage s = new EnableSimulatorMessage();
            s.Simulators = new EnableSimulatorMessage.SimulatorInfoBlock[2];

            EnableSimulatorMessage.SimulatorInfoBlock block1 = new EnableSimulatorMessage.SimulatorInfoBlock();
            block1.IP = testIP;
            block1.Port = 3000;
            block1.RegionHandle = testHandle;
            s.Simulators[0] = block1;

            EnableSimulatorMessage.SimulatorInfoBlock block2 = new EnableSimulatorMessage.SimulatorInfoBlock();
            block2.IP = testIP;
            block2.Port = 3001;
            block2.RegionHandle = testHandle;
            s.Simulators[1] = block2;

            OSDMap map = s.Serialize();

            EnableSimulatorMessage t = new EnableSimulatorMessage();
            t.Deserialize(map);

            for (int i = 0; i < t.Simulators.Length; i++)
            {
                Assert.AreEqual(s.Simulators[i].IP, t.Simulators[i].IP);
                Assert.AreEqual(s.Simulators[i].Port, t.Simulators[i].Port);
                Assert.AreEqual(s.Simulators[i].RegionHandle, t.Simulators[i].RegionHandle);
            }
        }
示例#2
0
        private bool RezChildAgentReplyHandler(LLAgent agent, OSDMap map, out IPAddress simHost, out int simPort, out Uri seedCapability)
        {
            simHost = null;
            simPort = 0;
            seedCapability = null;

            if (map["connect"].AsBoolean())
            {
                #region Response Parsing

                string simHostStr = map["sim_host"].AsString();
                if (!IPAddress.TryParse(simHostStr, out simHost))
                {
                    m_log.Warn("rez_avatar/response had an invalid sim_host: " + simHostStr);
                    return false;
                }

                simPort = map["sim_port"].AsInteger();
                UUID regionID = map["region_id"].AsUUID();

                uint regionX = map["region_x"].AsUInteger();
                uint regionY = map["region_y"].AsUInteger();
                ulong regionHandle = Utils.UIntsToLong(regionX, regionY);

                seedCapability = map["region_seed_capability"].AsUri();
                if (seedCapability == null)
                {
                    m_log.Warn("rez_avatar/response had an invalid region_seed_capability: " + map["region_seed_capability"].AsString());
                    return false;
                }

                #endregion Response Parsing

                #region EnableSimulator

                EnableSimulatorMessage.SimulatorInfoBlock block = new EnableSimulatorMessage.SimulatorInfoBlock();
                block.IP = simHost;
                block.Port = simPort;
                block.RegionHandle = regionHandle;

                EnableSimulatorMessage enable = new EnableSimulatorMessage();
                enable.Simulators = new EnableSimulatorMessage.SimulatorInfoBlock[1];
                enable.Simulators[0] = block;

                m_log.Debug("Sending EnableSimulator message for scene " + regionID + " to " + agent.Name);
                agent.EventQueue.QueueEvent("EnableSimulator", enable.Serialize());

                #endregion EnableSimulator

                #region EstablishAgentCommunication

                // Send an EstablishAgentCommunication event down to the client to get the neighbor event queue established
                EstablishAgentCommunicationMessage eacMessage = new EstablishAgentCommunicationMessage();
                eacMessage.AgentID = regionID;
                eacMessage.Address = simHost;
                eacMessage.Port = simPort;
                eacMessage.SeedCapability = seedCapability;

                m_log.Debug("Sending EstablishAgentCommunication message for seedcap " + seedCapability + " to " + agent.Name);
                agent.EventQueue.QueueEvent("EstablishAgentCommunication", eacMessage.Serialize());

                #endregion EstablishAgentCommunication

                return true;
            }
            else
            {
                m_log.Warn("rez_avatar/request from " + m_scene.Name + " for child agent " + agent.Name +
                    " failed: " + map["message"].AsString());
                return false;
            }
        }