OpenMetaverse.Messages.Linden.ChatterBoxInvitationMessage.Deserialize C# (CSharp) Method

Deserialize() public method

Deserialize the message
public Deserialize ( OSDMap map ) : void
map OSDMap An containing the data
return void
        public void Deserialize(OSDMap map)
        {
            if (map.ContainsKey("voice"))
            {
                FromAgentID = map["from_id"].AsUUID();
                FromAgentName = map["from_name"].AsString();
                IMSessionID = map["session_id"].AsUUID();
                BinaryBucket = Utils.StringToBytes(map["session_name"].AsString());
                Voice = true;
            }
            else
            {
                OSDMap im = (OSDMap)map["instantmessage"];
                OSDMap msg = (OSDMap)im["message_params"];
                OSDMap msgdata = (OSDMap)msg["data"];

                FromAgentID = msg["from_id"].AsUUID();
                FromAgentName = msg["from_name"].AsString();
                ToAgentID = msg["to_id"].AsUUID();
                ParentEstateID = (uint)msg["parent_estate_id"].AsInteger();
                RegionID = msg["region_id"].AsUUID();
                Position = msg["position"].AsVector3();
                GroupIM = msg["from_group"].AsBoolean();
                IMSessionID = msg["id"].AsUUID();
                Message = msg["message"].AsString();
                Offline = (InstantMessageOnline)msg["offline"].AsInteger();
                Dialog = (InstantMessageDialog)msgdata["type"].AsInteger();
                BinaryBucket = msgdata["binary_bucket"].AsBinary();
                Timestamp = msgdata["timestamp"].AsDate();
                Voice = false;
            }
        }
    }

Usage Example

        public void ChatterBoxInvitationMessage()
        {
            ChatterBoxInvitationMessage s = new ChatterBoxInvitationMessage();
            s.BinaryBucket = Utils.EmptyBytes;
            s.Dialog = InstantMessageDialog.InventoryOffered;
            s.FromAgentID = UUID.Random();
            s.FromAgentName = "Prokofy Neva";
            s.GroupIM = false;
            s.IMSessionID = s.FromAgentID ^ UUID.Random();
            s.Message = "Test Test Test";
            s.Offline = InstantMessageOnline.Online;
            s.ParentEstateID = 1;
            s.Position = Vector3.One;
            s.RegionID = UUID.Random();
            s.Timestamp = DateTime.UtcNow;
            s.ToAgentID = UUID.Random();

            OSDMap map = s.Serialize();

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

            Assert.AreEqual(s.BinaryBucket, t.BinaryBucket);
            Assert.AreEqual(s.Dialog, t.Dialog);
            Assert.AreEqual(s.FromAgentID, t.FromAgentID);
            Assert.AreEqual(s.FromAgentName, t.FromAgentName);
            Assert.AreEqual(s.GroupIM, t.GroupIM);
            Assert.AreEqual(s.IMSessionID, t.IMSessionID);
            Assert.AreEqual(s.Message, t.Message);
            Assert.AreEqual(s.Offline, t.Offline);
            Assert.AreEqual(s.ParentEstateID, t.ParentEstateID);
            Assert.AreEqual(s.Position, t.Position);
            Assert.AreEqual(s.RegionID, t.RegionID);
            Assert.AreEqual(s.Timestamp, t.Timestamp);
            Assert.AreEqual(s.ToAgentID, t.ToAgentID);
        }
ChatterBoxInvitationMessage