Ejemplo n.º 1
0
 private void UpdatePresenceSubscriptionWithChanges(PresenceInformation presence)
 {
     if (presence.Availability != PresenceInformation.NoChangeInAvailability)
     {
         m_presenceSubscriptionsBySipUri[presence.SipUri].Availability = presence.Availability;
     }
     if (presence.ContactName != PresenceInformation.NoChange)
     {
         m_presenceSubscriptionsBySipUri[presence.SipUri].ContactName = presence.ContactName;
     }
     if (presence.Status != PresenceInformation.NoChange)
     {
         m_presenceSubscriptionsBySipUri[presence.SipUri].Status = presence.Status;
     }
     if (presence.ActivityStatus != PresenceInformation.NoChange)
     {
         m_presenceSubscriptionsBySipUri[presence.SipUri].ActivityStatus = presence.ActivityStatus;
     }
 }
Ejemplo n.º 2
0
        void PresenceHandler(XElement Node)
        {
            string type = "available";

            if (Node.Attribute("type") != null)
            {
                type = Node.Attribute("type").Value;
            }

            switch (type)
            {
            case "subscribe":
                HandleSubscribe(Node);
                return;

            case "subscribed":
                HandleSubscribed(Node);
                return;

            case "unsubscribe":
                HandleUnsubscribe(Node);
                return;

            case "unsubscribed":
                HandleUnsubscribed(Node);
                return;
            }
            JID      From     = new JID(Node.Attribute("from").Value);
            int      Priority = 0;
            XElement PrioNode = Node.XPathSelectElement("//priority");

            if (PrioNode != null)
            {
                Priority = Convert.ToInt32(PrioNode.Value);
            }

            string Show   = string.Empty;
            string Status = string.Empty;

            XElement ShowNode = Node.XPathSelectElement("//show");

            if (ShowNode != null)
            {
                Show = ShowNode.Value;
            }
            XElement StatusNode = Node.XPathSelectElement("//status");

            if (StatusNode != null)
            {
                Show = StatusNode.Value;
            }

            PresenceInformation PI = new PresenceInformation()
            {
                FullJID  = From,
                Priority = Priority,
                Show     = Show,
                Status   = Status
            };

            if (!AggregatedPresence.ContainsKey(From.GetBareJID()))
            {
                AggregatedPresence[From.GetBareJID()] = new List <PresenceInformation>();
            }
            AggregatedPresence[From.GetBareJID()].Add(PI);

            if (OnPresence != null)
            {
                OnPresence.Invoke(From, Status != "unavailable", Priority, Status, Show);
            }
        }