예제 #1
0
 public virtual int OnDialogEvent(DialogEvent e)
 {
     return(this.SwigDerivedClassHasMethod("OnDialogEvent", SipCallback.swigMethodTypes0) ? tinyWRAPPINVOKE.SipCallback_OnDialogEventSwigExplicitSipCallback(this.swigCPtr, DialogEvent.getCPtr(e)) : tinyWRAPPINVOKE.SipCallback_OnDialogEvent(this.swigCPtr, DialogEvent.getCPtr(e)));
 }
예제 #2
0
 internal static HandleRef getCPtr(DialogEvent obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
예제 #3
0
            /// <summary>
            /// Dialog events (Common to all)
            /// </summary>
            /// <param name="e"></param>
            /// <returns></returns>
            public override int OnDialogEvent(DialogEvent e)
            {
                String phrase = e.getPhrase();
                short code = e.getCode();
                SipSession session = e.getBaseSession();
                if (session == null)
                {
                    return 0;
                }

                uint sessionId = session.getId();
                MySipSession mySession = null;

                SipService.LOG.Info(String.Format("OnDialogEvent ({0})", phrase));

                if (code == tinyWRAP.tsip_event_code_dialog_connecting)
                {
                    // Registration
                    if (this.sipService.regSession != null && this.sipService.regSession.Id == sessionId)
                    {
                        EventHandlerTrigger.TriggerEvent<RegistrationEventArgs>(this.sipService.onRegistrationEvent, this.sipService,
                            new RegistrationEventArgs(RegistrationEventTypes.REGISTRATION_INPROGRESS, code, phrase));
                    }
                    // Audio/Video/MSRP
                    else if (((mySession = MyAVSession.GetSession(sessionId)) != null) || ((mySession = MyMsrpSession.GetSession(sessionId)) != null))
                    {
                        (mySession as MyInviteSession).State = MyInviteSession.InviteState.INPROGRESS;
                        InviteEventArgs eargs = new InviteEventArgs(sessionId, InviteEventTypes.INPROGRESS, phrase);
                        eargs.AddExtra(InviteEventArgs.EXTRA_SESSION, mySession);
                        EventHandlerTrigger.TriggerEvent<InviteEventArgs>(this.sipService.onInviteEvent, this.sipService, eargs);
                    }

                    // Subscription

                    // Publication

                }

                else if (code == tinyWRAP.tsip_event_code_dialog_connected)
                {
                    // Registration
                    if (this.sipService.regSession != null && this.sipService.regSession.Id == sessionId)
                    {
                        this.sipService.regSession.IsConnected = true;
                        // Update default identity (vs barred)
                        String _defaultIdentity = this.sipService.SipStack.getPreferredIdentity();
                        if (!String.IsNullOrEmpty(_defaultIdentity))
                        {
                            this.sipService.defaultIdentity = _defaultIdentity;
                        }
                        // Do PostRegistrationOp() in new thread to avoid blocking callbacks
                        new Thread(new ThreadStart(delegate
                        {
                            this.sipService.DoPostRegistrationOp();
                        }))
                        .Start();
                        EventHandlerTrigger.TriggerEvent<RegistrationEventArgs>(this.sipService.onRegistrationEvent, this.sipService,
                            new RegistrationEventArgs(RegistrationEventTypes.REGISTRATION_OK, code, phrase));
                    }

                    // Audio/Video/MSRP
                    else if (((mySession = MyAVSession.GetSession(sessionId)) != null) || ((mySession = MyMsrpSession.GetSession(sessionId)) != null))
                    {
                        (mySession as MyInviteSession).State = MyInviteSession.InviteState.INCALL;
                        mySession.IsConnected = true;
                        EventHandlerTrigger.TriggerEvent<InviteEventArgs>(this.sipService.onInviteEvent, this.sipService, new InviteEventArgs(sessionId, InviteEventTypes.CONNECTED, phrase));
                    }

                    // Subscription
                    else if ((mySession = this.sipService.subPresence.FirstOrDefault(x => x.Id == sessionId)) != null)
                    {
                        mySession.IsConnected = true;
                    }

                    // Publication
                    else if (this.sipService.pubPres != null && this.sipService.pubPres.Id == sessionId)
                    {
                        this.sipService.pubPres.IsConnected = true;
                    }
                }

                else if (code == tinyWRAP.tsip_event_code_dialog_terminating)
                {
                    // Registration
                    if (this.sipService.regSession != null && this.sipService.regSession.Id == sessionId)
                    {
                        EventHandlerTrigger.TriggerEvent<RegistrationEventArgs>(this.sipService.onRegistrationEvent, this.sipService,
                            new RegistrationEventArgs(RegistrationEventTypes.UNREGISTRATION_INPROGRESS, code, phrase));
                    }

                    // Audio/Video/MSRP
                    else if (((mySession = MyAVSession.GetSession(sessionId)) != null) || ((mySession = MyMsrpSession.GetSession(sessionId)) != null))
                    {
                        (mySession as MyInviteSession).State = MyInviteSession.InviteState.TERMINATING;
                        EventHandlerTrigger.TriggerEvent<InviteEventArgs>(this.sipService.onInviteEvent, this.sipService, new InviteEventArgs(sessionId, InviteEventTypes.TERMWAIT, phrase));
                    }

                    // Subscription

                    // Publication
                }

                else if (code == tinyWRAP.tsip_event_code_dialog_terminated)
                {
                    // Registration
                    if (this.sipService.regSession != null && this.sipService.regSession.Id == sessionId)
                    {
                        this.sipService.regSession.IsConnected = false;
                        // To PostRegistration() in new thread
                        EventHandlerTrigger.TriggerEvent<RegistrationEventArgs>(this.sipService.onRegistrationEvent, this.sipService,
                            new RegistrationEventArgs(RegistrationEventTypes.UNREGISTRATION_OK, code, phrase));
                        /* Stop the stack (as we are already in the stack-thread, then do it in a new thread) */
                        new Thread(new ThreadStart(delegate
                        {
                            if (this.sipService.sipStack.State == MySipStack.STACK_STATE.STARTED)
                            {
                                this.sipService.sipStack.stop();
                            }
                        })).Start();
                    }

                    // Audio/Video/MSRP
                    else if (((mySession = MyAVSession.GetSession(sessionId)) != null) || ((mySession = MyMsrpSession.GetSession(sessionId)) != null))
                    {
                        mySession.IsConnected = false;
                        (mySession as MyInviteSession).State = MyInviteSession.InviteState.TERMINATED;
                        EventHandlerTrigger.TriggerEvent<InviteEventArgs>(this.sipService.onInviteEvent, this.sipService, new InviteEventArgs(sessionId, InviteEventTypes.DISCONNECTED, phrase));
                    }

                    // Subscription
                    else if ((mySession = this.sipService.subPresence.FirstOrDefault(x => x.Id == sessionId)) != null)
                    {
                        mySession.IsConnected = false;
                        this.sipService.subPresence.Remove(mySession as MySubscriptionSession);
                    }

                    // Publication
                    else if (this.sipService.pubPres != null && this.sipService.pubPres.Id == sessionId)
                    {
                        this.sipService.pubPres.IsConnected = false;
                        if (this.sipService.hyperAvailabilityTimer != null)
                        {
                            if (this.sipService.hyperAvailabilityTimer.Enabled)
                            {
                                this.sipService.hyperAvailabilityTimer.Stop();
                            }
                            this.sipService.hyperAvailabilityTimer = null;
                        }
                    }
                }

                return 0;
            }
예제 #4
0
 internal static HandleRef getCPtr(DialogEvent obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
예제 #5
0
 public virtual int OnDialogEvent(DialogEvent e) {
   int ret = (SwigDerivedClassHasMethod("OnDialogEvent", swigMethodTypes0) ? tinyWRAPPINVOKE.SipCallback_OnDialogEventSwigExplicitSipCallback(swigCPtr, DialogEvent.getCPtr(e)) : tinyWRAPPINVOKE.SipCallback_OnDialogEvent(swigCPtr, DialogEvent.getCPtr(e)));
   return ret;
 }
예제 #6
0
        public virtual int OnDialogEvent(DialogEvent e)
        {
            int ret = (SwigDerivedClassHasMethod("OnDialogEvent", swigMethodTypes0) ? tinyWRAPPINVOKE.SipCallback_OnDialogEventSwigExplicitSipCallback(swigCPtr, DialogEvent.getCPtr(e)) : tinyWRAPPINVOKE.SipCallback_OnDialogEvent(swigCPtr, DialogEvent.getCPtr(e)));

            return(ret);
        }
예제 #7
0
        public virtual int OnDialogEvent(DialogEvent e)
        {
            int ret = ((this.GetType() == typeof(SipCallback)) ? tinyWRAPPINVOKE.SipCallback_OnDialogEvent(swigCPtr, DialogEvent.getCPtr(e)) : tinyWRAPPINVOKE.SipCallback_OnDialogEventSwigExplicitSipCallback(swigCPtr, DialogEvent.getCPtr(e)));

            return(ret);
        }
예제 #8
0
 public virtual int OnDialogEvent(DialogEvent e) {
   int ret = ((this.GetType() == typeof(SipCallback)) ? tinyWRAPPINVOKE.SipCallback_OnDialogEvent(swigCPtr, DialogEvent.getCPtr(e)) : tinyWRAPPINVOKE.SipCallback_OnDialogEventSwigExplicitSipCallback(swigCPtr, DialogEvent.getCPtr(e)));
   return ret;
 }