예제 #1
0
        private void contactService_onContactEvent(object sender, ContactEventArgs e)
        {
            if (!this.IsSubscriptionEnabled || this.IsSubscriptionToRLSEnabled)
            {
                return;
            }

            switch (e.Type)
            {
                case ContactEventTypes.CONTACT_ADDED:
                    {
                        MySubscriptionSession session = new MySubscriptionSession(mSipStack,  (e.GetExtra(ContactEventArgs.EXTRA_CONTACT) as Contact).UriString,
                            MySubscriptionSession.EVENT_PACKAGE_TYPE.PRESENCE);
                        this.mSubPresence.Add(session);
                        session.Subscribe();
                        break;
                    }

                case ContactEventTypes.CONTACT_REMOVED:
                    {
                        MySubscriptionSession session = this.mSubPresence.FirstOrDefault(x => String.Equals(x.ToUri, (e.GetExtra(ContactEventArgs.EXTRA_CONTACT) as Contact).UriString));
                        if (session != null)
                        {
                            if (session.IsConnected)
                            {
                                session.UnSubscribe();
                            }
                            this.mSubPresence.Remove(session);
                        }
                        break;
                    }

                case ContactEventTypes.RESET:
                    {
                        this.mSubPresence.ForEach(x=>
                        {
                            if (x.IsConnected) x.UnSubscribe();
                        });

                        foreach (Contact contact in this.contactService.Contacts)
                        {
                            MySubscriptionSession session = new MySubscriptionSession(mSipStack, contact.UriString, MySubscriptionSession.EVENT_PACKAGE_TYPE.PRESENCE);
                            this.mSubPresence.Add(session);
                            session.Subscribe();
                        }
                        break;
                    }
            }
        }
예제 #2
0
        private void contactService_onContactEvent(object sender, ContactEventArgs e)
        {
            if (e.Type != ContactEventTypes.RESET && e.Type != ContactEventTypes.GROUP_UPDATED && e.Type != ContactEventTypes.GROUP_REMOVED)
            {
                return;
            }

            if (this.Dispatcher.Thread != Thread.CurrentThread)
            {
                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                        new EventHandler<ContactEventArgs>(this.contactService_onContactEvent), sender, new object[] { e });
                return;
            }

            this.UpdateSource();
        }
예제 #3
0
 private void GroupSignal(Group group, ContactEventTypes eventType)
 {
     ContactEventArgs eargs = new ContactEventArgs(eventType);
     eargs.AddExtra(ContactEventArgs.EXTRA_GROUP, group);
     EventHandlerTrigger.TriggerEvent<ContactEventArgs>(this.onContactEvent, this, eargs);
 }
예제 #4
0
 private void ContactSignal(Contact contact, ContactEventTypes eventType)
 {
     ContactEventArgs eargs = new ContactEventArgs(eventType);
     eargs.AddExtra(ContactEventArgs.EXTRA_CONTACT, contact);
     EventHandlerTrigger.TriggerEvent<ContactEventArgs>(this.onContactEvent, this, eargs);
 }