Serialize() публичный Метод

Serialize the object
public Serialize ( ) : OSDMap
Результат OSDMap
        public void ParcelPropertiesUpdateMessage()
        {
            ParcelPropertiesUpdateMessage s = new ParcelPropertiesUpdateMessage();
            s.AuthBuyerID = UUID.Random();
            s.Category = ParcelCategory.Gaming;
            s.Desc = "Example Description";
            s.GroupID = UUID.Random();
            s.Landing = LandingType.LandingPoint;
            s.LocalID = 160;
            s.MediaAutoScale = true;
            s.MediaDesc = "Example Media Description";
            s.MediaHeight = 600;
            s.MediaID = UUID.Random();
            s.MediaLoop = false;
            s.MediaType = "image/jpeg";
            s.MediaURL = "http://www.openmetaverse.co/test.jpeg";
            s.MediaWidth = 800;
            s.MusicURL = "http://scfire-ntc-aa04.stream.aol.com:80/stream/1075";
            s.Name = "Example Parcel Description";
            s.ObscureMedia = true;
            s.ObscureMusic = true;
            s.ParcelFlags = ParcelFlags.AllowVoiceChat | ParcelFlags.ContributeWithDeed;
            s.PassHours = 5.5f;
            s.PassPrice = 100;
            s.SalePrice = 99;
            s.SnapshotID = UUID.Random();
            s.UserLocation = Vector3.Parse("<128,128,128>");
            s.UserLookAt = Vector3.Parse("<256,256,256>");

            OSDMap map = s.Serialize();

            ParcelPropertiesUpdateMessage t = new ParcelPropertiesUpdateMessage();

            t.Deserialize(map);

            Assert.AreEqual(s.AuthBuyerID, t.AuthBuyerID);
            Assert.AreEqual(s.Category, t.Category);
            Assert.AreEqual(s.Desc, t.Desc);
            Assert.AreEqual(s.GroupID, t.GroupID);
            Assert.AreEqual(s.Landing, t.Landing);
            Assert.AreEqual(s.LocalID, t.LocalID);
            Assert.AreEqual(s.MediaAutoScale, t.MediaAutoScale);
            Assert.AreEqual(s.MediaDesc, t.MediaDesc);
            Assert.AreEqual(s.MediaHeight, t.MediaHeight);
            Assert.AreEqual(s.MediaID, t.MediaID);
            Assert.AreEqual(s.MediaLoop, t.MediaLoop);
            Assert.AreEqual(s.MediaType, t.MediaType);
            Assert.AreEqual(s.MediaURL, t.MediaURL);
            Assert.AreEqual(s.MediaWidth, t.MediaWidth);
            Assert.AreEqual(s.MusicURL, t.MusicURL);
            Assert.AreEqual(s.Name, t.Name);
            Assert.AreEqual(s.ObscureMedia, t.ObscureMedia);
            Assert.AreEqual(s.ObscureMusic, t.ObscureMusic);
            Assert.AreEqual(s.ParcelFlags, t.ParcelFlags);
            Assert.AreEqual(s.PassHours, t.PassHours);
            Assert.AreEqual(s.PassPrice, t.PassPrice);
            Assert.AreEqual(s.SalePrice, t.SalePrice);
            Assert.AreEqual(s.SnapshotID, t.SnapshotID);
            Assert.AreEqual(s.UserLocation, t.UserLocation);
            Assert.AreEqual(s.UserLookAt, t.UserLookAt);
        }
Пример #2
0
        /// <summary>
        /// Update the simulator with any local changes to this Parcel object
        /// </summary>
        /// <param name="simulator">Simulator to send updates to</param>
        /// <param name="wantReply">Whether we want the simulator to confirm
        /// the update with a reply packet or not</param>
        public void Update(Simulator simulator, bool wantReply)
        {
            Uri url = simulator.Caps.CapabilityURI("ParcelPropertiesUpdate");

            if (url != null)
            {
                ParcelPropertiesUpdateMessage req = new ParcelPropertiesUpdateMessage();
                req.AuthBuyerID = this.AuthBuyerID;
                req.Category = this.Category;
                req.Desc = this.Desc;
                req.GroupID = this.GroupID;
                req.Landing = this.Landing;
                req.LocalID = this.LocalID;
                req.MediaAutoScale = this.Media.MediaAutoScale;
                req.MediaDesc = this.Media.MediaDesc;
                req.MediaHeight = this.Media.MediaHeight;
                req.MediaID = this.Media.MediaID;
                req.MediaLoop = this.Media.MediaLoop;
                req.MediaType = this.Media.MediaType;
                req.MediaURL = this.Media.MediaURL;
                req.MediaWidth = this.Media.MediaWidth;
                req.MusicURL = this.MusicURL;
                req.Name = this.Name;
                req.ObscureMedia = this.ObscureMedia;
                req.ObscureMusic = this.ObscureMusic;
                req.ParcelFlags = this.Flags;
                req.PassHours = this.PassHours;
                req.PassPrice = (uint)this.PassPrice;
                req.SalePrice = (uint)this.SalePrice;
                req.SnapshotID = this.SnapshotID;
                req.UserLocation = this.UserLocation;
                req.UserLookAt = this.UserLookAt;
               
                OSDMap body = req.Serialize();

                CapsClient capsPost = new CapsClient(url);
                capsPost.BeginGetResponse(body, OSDFormat.Xml, simulator.Client.Settings.CAPS_TIMEOUT);
            }
            else
            {
                ParcelPropertiesUpdatePacket request = new ParcelPropertiesUpdatePacket();

                request.AgentData.AgentID = simulator.Client.Self.AgentID;
                request.AgentData.SessionID = simulator.Client.Self.SessionID;

                request.ParcelData.LocalID = this.LocalID;

                request.ParcelData.AuthBuyerID = this.AuthBuyerID;
                request.ParcelData.Category = (byte)this.Category;
                request.ParcelData.Desc = Utils.StringToBytes(this.Desc);
                request.ParcelData.GroupID = this.GroupID;
                request.ParcelData.LandingType = (byte)this.Landing;
                request.ParcelData.MediaAutoScale = (this.Media.MediaAutoScale) ? (byte)0x1 : (byte)0x0;
                request.ParcelData.MediaID = this.Media.MediaID;
                request.ParcelData.MediaURL = Utils.StringToBytes(this.Media.MediaURL.ToString());
                request.ParcelData.MusicURL = Utils.StringToBytes(this.MusicURL.ToString());
                request.ParcelData.Name = Utils.StringToBytes(this.Name);
                if (wantReply) request.ParcelData.Flags = 1;
                request.ParcelData.ParcelFlags = (uint)this.Flags;
                request.ParcelData.PassHours = this.PassHours;
                request.ParcelData.PassPrice = this.PassPrice;
                request.ParcelData.SalePrice = this.SalePrice;
                request.ParcelData.SnapshotID = this.SnapshotID;
                request.ParcelData.UserLocation = this.UserLocation;
                request.ParcelData.UserLookAt = this.UserLookAt;

                simulator.SendPacket(request);
            }

            UpdateOtherCleanTime(simulator);
            
        }
Пример #3
0
        /// <summary>
        /// Update the simulator with any local changes to this Parcel object
        /// </summary>
        /// <param name="simulator">Simulator to send updates to</param>
        /// <param name="wantReply">Whether we want the simulator to confirm
        /// the update with a reply packet or not</param>
        public void Update(Simulator simulator, bool wantReply)
        {
            Uri url = simulator.Caps.CapabilityURI("ParcelPropertiesUpdate");

            if (url != null)
            {
                ParcelPropertiesUpdateMessage req = new ParcelPropertiesUpdateMessage();
                req.AuthBuyerID = this.AuthBuyerID;
                req.Category = this.Category;
                req.Desc = this.Desc;
                req.GroupID = this.GroupID;
                req.Landing = this.Landing;
                req.LocalID = this.LocalID;
                req.MediaAutoScale = this.Media.MediaAutoScale;
                req.MediaDesc = this.Media.MediaDesc;
                req.MediaHeight = this.Media.MediaHeight;
                req.MediaID = this.Media.MediaID;
                req.MediaLoop = this.Media.MediaLoop;
                req.MediaType = this.Media.MediaType;
                req.MediaURL = this.Media.MediaURL;
                req.MediaWidth = this.Media.MediaWidth;
                req.MusicURL = this.MusicURL;
                req.Name = this.Name;
                req.ObscureMedia = this.ObscureMedia;
                req.ObscureMusic = this.ObscureMusic;
                req.ParcelFlags = this.Flags;
                req.PassHours = this.PassHours;
                req.PassPrice = (uint)this.PassPrice;
                req.SalePrice = (uint)this.SalePrice;
                req.SnapshotID = this.SnapshotID;
                req.UserLocation = this.UserLocation;
                req.UserLookAt = this.UserLookAt;

                //OSDMap body = new OSDMap();
                //body["auth_buyer_id"] =  OSD.FromUUID(this.AuthBuyerID);
                //body["auto_scale"] =  OSD.FromBoolean(this.Media.MediaAutoScale);
                //body["category"] = OSD.FromInteger((byte)this.Category);
                //body["description"] = OSD.FromString(this.Desc);
                //body["flags"] =  OSD.FromBinary(Utils.EmptyBytes);
                //body["group_id"] = OSD.FromUUID(this.GroupID);
                //body["landing_type"] = OSD.FromInteger((byte)this.Landing);
                //body["local_id"] = OSD.FromInteger(this.LocalID);
                //body["media_desc"] = OSD.FromString(this.Media.MediaDesc);
                //body["media_height"] = OSD.FromInteger(this.Media.MediaHeight);
                //body["media_id"] = OSD.FromUUID(this.Media.MediaID);
                //body["media_loop"] = OSD.FromInteger(this.Media.MediaLoop ? 1 : 0);
                //body["media_type"] = OSD.FromString(this.Media.MediaType);
                //body["media_url"] = OSD.FromString(this.Media.MediaURL);
                //body["media_width"] = OSD.FromInteger(this.Media.MediaWidth);
                //body["music_url"] = OSD.FromString(this.MusicURL);
                //body["name"] = OSD.FromString(this.Name);
                //body["obscure_media"]= OSD.FromInteger(this.ObscureMedia ? 1 : 0);
                //body["obscure_music"] = OSD.FromInteger(this.ObscureMusic ? 1 : 0);

                //byte[] flags = Utils.IntToBytes((int)this.Flags); ;
                //if (BitConverter.IsLittleEndian)
                //    Array.Reverse(flags);
                //body["parcel_flags"] = OSD.FromBinary(flags);

                //body["pass_hours"] = OSD.FromReal(this.PassHours);
                //body["pass_price"] = OSD.FromInteger(this.PassPrice);
                //body["sale_price"] = OSD.FromInteger(this.SalePrice);
                //body["snapshot_id"] = OSD.FromUUID(this.SnapshotID);
                //OSDArray uloc = new OSDArray();
                //uloc.Add(OSD.FromReal(this.UserLocation.X));
                //uloc.Add(OSD.FromReal(this.UserLocation.Y));
                //uloc.Add(OSD.FromReal(this.UserLocation.Z));
                //body["user_location"] = uloc;
                //OSDArray ulat = new OSDArray();
                //ulat.Add(OSD.FromReal(this.UserLocation.X));
                //ulat.Add(OSD.FromReal(this.UserLocation.Y));
                //ulat.Add(OSD.FromReal(this.UserLocation.Z));
                //body["user_look_at"] = ulat;

                OSDMap body = req.Serialize();

                CapsClient capsPost = new CapsClient(url);
                capsPost.BeginGetResponse(body, OSDFormat.Xml, simulator.Network.CapsTimeout);
            }
            else
            {
                ParcelPropertiesUpdatePacket request = new ParcelPropertiesUpdatePacket();

                request.AgentData.AgentID = simulator.Network.AgentID;
                request.AgentData.SessionID = simulator.Network.SessionID;

                request.ParcelData.LocalID = this.LocalID;

                request.ParcelData.AuthBuyerID = this.AuthBuyerID;
                request.ParcelData.Category = (byte)this.Category;
                request.ParcelData.Desc = Utils.StringToBytes(this.Desc);
                request.ParcelData.GroupID = this.GroupID;
                request.ParcelData.LandingType = (byte)this.Landing;
                request.ParcelData.MediaAutoScale = (this.Media.MediaAutoScale) ? (byte)0x1 : (byte)0x0;
                request.ParcelData.MediaID = this.Media.MediaID;
                request.ParcelData.MediaURL = Utils.StringToBytes(this.Media.MediaURL.ToString());
                request.ParcelData.MusicURL = Utils.StringToBytes(this.MusicURL.ToString());
                request.ParcelData.Name = Utils.StringToBytes(this.Name);
                if (wantReply) request.ParcelData.Flags = 1;
                request.ParcelData.ParcelFlags = (uint)this.Flags;
                request.ParcelData.PassHours = this.PassHours;
                request.ParcelData.PassPrice = this.PassPrice;
                request.ParcelData.SalePrice = this.SalePrice;
                request.ParcelData.SnapshotID = this.SnapshotID;
                request.ParcelData.UserLocation = this.UserLocation;
                request.ParcelData.UserLookAt = this.UserLookAt;

                simulator.SendPacket(request);
            }

            UpdateOtherCleanTime(simulator);
            
        }