Example #1
0
        /// <summary>
        /// Generates a BYE request for this dialog and forwards it to the remote call party.
        /// This has the effect of hanging up the call.
        /// </summary>
        /// <param name="sipTransport">The transport layer to use for sending the request.</param>
        /// <param name="outboundProxy">Optional. If set an end point that the BYE request will be directly forwarded to.</param>
        public void Hangup(SIPTransport sipTransport, SIPEndPoint outboundProxy)
        {
            try
            {
                DialogueState = SIPDialogueStateEnum.Terminated;

                SIPEndPoint byeOutboundProxy = null;
                if (outboundProxy != null && IPAddress.IsLoopback(outboundProxy.Address))
                {
                    byeOutboundProxy = outboundProxy;
                }
                else if (!ProxySendFrom.IsNullOrBlank())
                {
                    byeOutboundProxy =
                        new SIPEndPoint(new IPEndPoint(SIPEndPoint.ParseSIPEndPoint(ProxySendFrom).Address,
                                                       m_defaultSIPPort));
                }
                else if (outboundProxy != null)
                {
                    byeOutboundProxy = outboundProxy;
                }

                SIPRequest byeRequest = GetInDialogRequest(SIPMethodsEnum.BYE);
                SIPNonInviteTransaction byeTransaction =
                    new SIPNonInviteTransaction(sipTransport, byeRequest, byeOutboundProxy);
                byeTransaction.SendRequest();
            }
            catch (Exception excp)
            {
                logger.LogError("Exception SIPDialogue Hangup. " + excp.Message);
            }
        }