Пример #1
0
        public void SaveVCard()
        {
            IQ iq = new IQ(m_Client.Document);

            iq.Type = IQType.set;

            var vcard = m_Client.Document.ImportNode(m_MyVCard, true);

            iq.AppendChild(vcard);

            m_IQTracker.BeginIQ(iq, delegate(object o, IQ result, object cbArg) {
                if (result.Type == IQType.error)
                {
                    Console.WriteLine("Failed to set VCard!");
                }
            }, null);


            if (MyVCardUpdated != null)
            {
                MyVCardUpdated(this, EventArgs.Empty);
            }
        }
Пример #2
0
        public void AddRosterItem(JID jid, string name, string[] groups, IqCB callback)
        {
            var iq = new IQ(m_Client.Document);

            iq.Type = IQType.set;

            var item = new Item(m_Client.Document);

            item.JID      = jid;
            item.Nickname = name;

            if (groups != null)
            {
                foreach (var groupName in groups)
                {
                    var group = new Group(m_Client.Document);
                    group.GroupName = groupName;
                    item.AppendChild(group);
                }
            }

            iq.AppendChild(item);

            m_IQTracker.BeginIQ(iq, delegate(object sender, IQ response, object data) {
                if (response.Type != IQType.error)
                {
                    Presence presence = new Presence(m_Client.Document);
                    presence.To       = jid;
                    presence.Type     = PresenceType.subscribe;
                    m_Client.Write(presence);
                }
                if (callback != null)
                {
                    callback(sender, iq, data);
                }
            }, this);
        }