Beispiel #1
0
 private void OnSubscriptionEvent(object sender, SubscriptionEventArgs e)
 {
     if (null != e)
     {
         MySubscriptionSession  session = this.FindSubcribSenssion(e.SessionId);
         SubscriptionEventTypes type    = e.Type;
         if (type != SubscriptionEventTypes.SUBSCRIPTION_OK)
         {
             if (type != SubscriptionEventTypes.UNSUBSCRIPTION_OK)
             {
                 if (type != SubscriptionEventTypes.INCOMING_NOTIFY)
                 {
                 }
             }
             else
             {
                 session.IsConnected = false;
             }
         }
         else
         {
             session.IsConnected = true;
         }
     }
 }
Beispiel #2
0
        public MySubscriptionSession FindSubcribSenssion(long iSessionId)
        {
            MySubscriptionSession result;

            foreach (System.Collections.Generic.KeyValuePair <long, MySubscriptionSession> senssionPair in this.termSubSessions)
            {
                MySubscriptionSession senssionReturn = senssionPair.Value;
                if (senssionReturn.Id == iSessionId)
                {
                    result = senssionReturn;
                    return(result);
                }
            }
            foreach (System.Collections.Generic.KeyValuePair <long, MySubscriptionSession> senssionPair in this.grpSubSessions)
            {
                MySubscriptionSession senssionReturn = senssionPair.Value;
                if (senssionReturn.Id == iSessionId)
                {
                    result = senssionReturn;
                    return(result);
                }
            }
            result = null;
            return(result);
        }
Beispiel #3
0
        public bool SubscribeGroupStatus(Group g)
        {
            MySubscriptionSession session = new MySubscriptionSession(this.manager.StackService.SipStack, g.Uri, MySubscriptionSession.EVENT_PACKAGE_TYPE.PTT_GRCALL_SUB);

            session.FromUri = this.Identity;
            this.grpSubSessions.Add(session.Id, session);
            return(session.Subscribe());
        }
Beispiel #4
0
        public bool SubscribeUserMemberShip(Person p)
        {
            MySubscriptionSession session = new MySubscriptionSession(this.manager.StackService.SipStack, p.Uri, MySubscriptionSession.EVENT_PACKAGE_TYPE.PTT_MEMBRELATION_SUB);

            session.FromUri = this.Identity;
            this.grpSubSessions.Add(session.Id, session);
            string strUheader = string.Format("pttsubscribe;utype={0}", 1);

            return(session.Subscribe(strUheader));
        }
 public SubscriptionEventArgs(SubscriptionEventTypes type, short sipCode, String phrase, byte[] content, String contentType, MySubscriptionSession.EVENT_PACKAGE_TYPE package)
     : base()
 {
     this.type = type;
     this.sipCode = sipCode;
     this.phrase = phrase;
     this.content = content;
     this.contentType = contentType;
     this.package = package;
 }
Beispiel #6
0
        public bool SubscribeTermStatus(string strUDN)
        {
            MySubscriptionSession session = new MySubscriptionSession(this.manager.StackService.SipStack, strUDN, MySubscriptionSession.EVENT_PACKAGE_TYPE.PTT_REG_SUB);

            session.FromUri = this.Identity;
            this.grpSubSessions.Add(session.Id, session);
            MySubscriptionSession session2 = new MySubscriptionSession(this.manager.StackService.SipStack, strUDN, MySubscriptionSession.EVENT_PACKAGE_TYPE.PTT_UECALL_SUB);

            session2.FromUri = this.Identity;
            this.grpSubSessions.Add(session2.Id, session2);
            return(session.Subscribe() & session2.Subscribe());
        }
Beispiel #7
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(this.sipStack, (e.GetExtra(ContactEventArgs.EXTRA_CONTACT) as Contact).UriString,
                                                                          MySubscriptionSession.EVENT_PACKAGE_TYPE.PRESENCE);
                this.subPresence.Add(session);
                session.Subscribe();
                break;
            }

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

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

                foreach (Contact contact in this.contactService.Contacts)
                {
                    MySubscriptionSession session = new MySubscriptionSession(this.sipStack, contact.UriString, MySubscriptionSession.EVENT_PACKAGE_TYPE.PRESENCE);
                    this.subPresence.Add(session);
                    session.Subscribe();
                }
                break;
            }
            }
        }
Beispiel #8
0
 private bool SubscribeToMWI()
 {
     if (this.subMwi == null)
     {
         this.subMwi = new MySubscriptionSession(this.manager.StackService.SipStack, this.Identity, MySubscriptionSession.EVENT_PACKAGE_TYPE.MESSAGE_SUMMARY);
     }
     else
     {
         this.subMwi.ToUri     = this.Identity;
         this.subMwi.FromUri   = this.Identity;
         this.subMwi.SigCompId = this.manager.StackService.SipStack.SigCompId;
     }
     return(this.subMwi.Subscribe());
 }
Beispiel #9
0
 private bool SubscribeToRegInfo()
 {
     if (this.subReg == null)
     {
         this.subReg = new MySubscriptionSession(this.manager.StackService.SipStack, this.Identity, MySubscriptionSession.EVENT_PACKAGE_TYPE.REG);
     }
     else
     {
         this.subReg.ToUri     = this.Identity;
         this.subReg.FromUri   = this.Identity;
         this.subReg.SigCompId = this.manager.StackService.SipStack.SigCompId;
     }
     return(this.subReg.Subscribe());
 }
Beispiel #10
0
        public bool GetRemoteContactsBySub()
        {
            string strToUri = this.serviceManager.ConfigurationService.IdentityCfg.Impu;

            if (this.subContact == null)
            {
                this.subContact = new MySubscriptionSession(this.serviceManager.StackService.SipStack, strToUri, MySubscriptionSession.EVENT_PACKAGE_TYPE.PTT_MEMBRELATION_SUB);
            }
            else
            {
                this.subContact.ToUri   = strToUri;
                this.subContact.FromUri = strToUri;
            }
            string strUheader = string.Format("pttsubscribe;utype={0}", 3);

            return(this.subContact.Subscribe(strUheader));
        }
Beispiel #11
0
 public void RemoveSubSension(string strKey)
 {
     foreach (System.Collections.Generic.KeyValuePair <long, MySubscriptionSession> senssionPair in this.termSubSessions)
     {
         MySubscriptionSession senssionReturn = senssionPair.Value;
         if (senssionReturn.ToUri == strKey)
         {
             this.termSubSessions.Remove(senssionReturn.Id);
         }
     }
     foreach (System.Collections.Generic.KeyValuePair <long, MySubscriptionSession> senssionPair in this.grpSubSessions)
     {
         MySubscriptionSession senssionReturn = senssionPair.Value;
         if (senssionReturn.ToUri == strKey)
         {
             this.termSubSessions.Remove(senssionReturn.Id);
         }
     }
 }
Beispiel #12
0
 public void UnSubscribeAll()
 {
     foreach (System.Collections.Generic.KeyValuePair <long, MySubscriptionSession> senssionPair in this.termSubSessions)
     {
         MySubscriptionSession senssionReturn = senssionPair.Value;
         if (senssionReturn != null)
         {
             senssionReturn.UnSubscribe();
         }
     }
     foreach (System.Collections.Generic.KeyValuePair <long, MySubscriptionSession> senssionPair in this.grpSubSessions)
     {
         MySubscriptionSession senssionReturn = senssionPair.Value;
         if (senssionReturn != null)
         {
             senssionReturn.UnSubscribe();
         }
     }
 }
Beispiel #13
0
 public System.Collections.Generic.List <MySubscriptionSession> FindSubcribSenssion(string strName)
 {
     System.Collections.Generic.List <MySubscriptionSession> senssionReturn = new System.Collections.Generic.List <MySubscriptionSession>();
     foreach (System.Collections.Generic.KeyValuePair <long, MySubscriptionSession> senssionPair in this.termSubSessions)
     {
         MySubscriptionSession senssiontem = senssionPair.Value;
         if (senssiontem.ToUri == strName)
         {
             senssionReturn.Add(senssiontem);
         }
     }
     foreach (System.Collections.Generic.KeyValuePair <long, MySubscriptionSession> senssionPair in this.grpSubSessions)
     {
         MySubscriptionSession senssiontem = senssionPair.Value;
         if (senssiontem.ToUri == strName)
         {
             senssionReturn.Add(senssiontem);
         }
     }
     return(senssionReturn);
 }