Example #1
0
        internal void UpdatePresence(XmppJid jid, Presence presence)
        {
            lock (this.syncObject)
            {
                XmppContactResource resource = this.resources
                    .Where(contactResource => contactResource.ResourceId.Equals(jid))
                    .SingleOrDefault();

                if (resource == null)
                {
                    resource = new XmppContactResource(this.session, this, jid);
                    this.resources.Add(resource);
                }

                resource.Update(presence);

                // Remove the resource information if the contact has gone offline
                if (!resource.IsDefaultResource &&
                    resource.Presence.PresenceStatus == XmppPresenceState.Offline)
                {
                    this.resources.Remove(resource);
                }

                this.NotifyPropertyChanged(() => Presence);
                this.NotifyPropertyChanged(() => Resource);
            }
        }
Example #2
0
        internal void AddDefaultResource()
        {
            Presence            defaultPresence = new Presence();
            XmppContactResource contactResource = new XmppContactResource(this.session, this, this.ContactId);
            XmppJid             resourceJid     = new XmppJid(this.contactId.UserName, this.ContactId.DomainName, Guid.NewGuid().ToString());

            // Add a default resource
            defaultPresence.TypeSpecified   = true;
            defaultPresence.From            = resourceJid;
            defaultPresence.Type            = PresenceType.Unavailable;

            defaultPresence.Items.Add(XmppContactResource.DefaultPresencePriorityValue);

            contactResource.Update(defaultPresence);

            this.resources.Add(contactResource);
        }