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);
            }
        }
Example #2
0
        /*public static string GetDialogueId(string callId, string localTag, string remoteTag)
         * {
         *  return Crypto.GetSHAHashAsString(callId + localTag + remoteTag);
         * }
         *
         * public static string GetDialogueId(SIPHeader sipHeader)
         * {
         *  return Crypto.GetSHAHashAsString(sipHeader.CallId + sipHeader.To.ToTag + sipHeader.From.FromTag);
         * }*/

        public void Hangup(SIPTransport sipTransport, SIPEndPoint outboundProxy)
        {
            try
            {
                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;
                }

                SIPEndPoint localEndPoint = (byeOutboundProxy != null)
                    ? sipTransport.GetDefaultSIPEndPoint(byeOutboundProxy.Protocol)
                    : sipTransport.GetDefaultSIPEndPoint(GetRemoteTargetProtocol());
                SIPRequest byeRequest = GetByeRequest(localEndPoint);
                SIPNonInviteTransaction byeTransaction =
                    sipTransport.CreateNonInviteTransaction(byeRequest, null, localEndPoint, byeOutboundProxy);
                byeTransaction.SendReliableRequest();
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPDialogue Hangup. " + excp.Message);
                throw;
            }
        }