Exemplo n.º 1
0
        void HandleSubscribe(XElement Node)
        {
            if (OnSubscribe == null)
            {
                return;
            }

            JID From = new JID(Node.Attribute("from").Value);
            SubscribeResponse Action = OnSubscribe.Invoke(From);

            if (Action == SubscribeResponse.Reject)
            {
                return;
            }

            XElement PresenceTag = new XElement("presence");

            PresenceTag.SetAttributeValue("to", From.GetBareJID());
            PresenceTag.SetAttributeValue("type", "subscribed");
            Uplink.GetNetworkClient().WriteTextToSocket(PresenceTag.ToString());

            if (Action == SubscribeResponse.Allow)
            {
                return;
            }

            Subscribe(From);
        }
Exemplo n.º 2
0
        public void Unsubscribe(JID To)
        {
            XElement PresenceTag = new XElement("presence");

            PresenceTag.SetAttributeValue("to", To.GetBareJID());
            PresenceTag.SetAttributeValue("type", "unsubscribe");
            Uplink.GetNetworkClient().WriteTextToSocket(PresenceTag.ToString());
        }