/// <summary>
        ///  Invite请求消息
        /// </summary>
        /// <param name="localEP"></param>
        /// <param name="remoteEP"></param>
        /// <param name="request"></param>
        private void InviteHandle(SIPEndPoint localEP, SIPEndPoint remoteEP, SIPRequest request)
        {
            _byeRemoteEP = remoteEP;
            int[] port   = SetMediaPort();
            var   trying = GetResponse(localEP, remoteEP, SIPResponseStatusCodesEnum.Trying, "", request);

            _transport.SendResponse(trying);
            //Thread.Sleep(200);
            SIPResponse audioOK = GetResponse(localEP, remoteEP, SIPResponseStatusCodesEnum.Ok, "", request);

            audioOK.Header.ContentType = "application/sdp";
            SIPURI           localUri = new SIPURI(LocalSIPId, LocalEP.ToHost(), "");
            SIPContactHeader contact  = new SIPContactHeader(null, localUri);

            audioOK.Header.Contact = new List <SIPContactHeader>
            {
                contact
            };
            //SDP
            audioOK.Body   = SetMediaAudio(localEP.Address.ToString(), port[0], request.URI.User);
            _audioResponse = audioOK;
            _transport.SendResponse(audioOK);
            int    recvPort = GetReceivePort(request.Body, SDPMediaTypesEnum.audio);
            string ip       = GetReceiveIP(request.Body);

            _audioRemoteEP = new IPEndPoint(IPAddress.Parse(ip), recvPort);
            if (_audioChannel == null)
            {
                _audioChannel = new UDPChannel(TcpConnectMode.active, IPAddress.Any, port, ProtocolType.Udp, false, recvPort);
            }
            _audioChannel.Start();
        }
        public void AddRegisterRequest(SIPEndPoint localSIPEndPoint, SIPEndPoint remoteEndPoint,
                                       SIPRequest registerRequest)
        {
            try
            {
                if (registerRequest.Method == SIPMethodsEnum.REGISTER)
                {
                    SIPSorceryPerformanceMonitor.IncrementCounter(SIPSorceryPerformanceMonitor
                                                                  .REGISTRAR_REGISTRATION_REQUESTS_PER_SECOND);

                    int requestedExpiry = GetRequestedExpiry(registerRequest);

                    if (registerRequest.Header.To == null)
                    {
                        Logger.Logger.Debug("Bad register request, no To header from " + remoteEndPoint + ".");
                        SIPResponse badReqResponse = SIPTransport.GetResponse(registerRequest,
                                                                              SIPResponseStatusCodesEnum.BadRequest, "Missing To header");
                        _sipTransport.SendResponse(badReqResponse);
                    }
                    else if (registerRequest.Header.To.ToURI.User.IsNullOrBlank())
                    {
                        Logger.Logger.Debug("Bad register request, no To user from " + remoteEndPoint + ".");
                        SIPResponse badReqResponse = SIPTransport.GetResponse(registerRequest,
                                                                              SIPResponseStatusCodesEnum.BadRequest, "Missing username on To header");
                        _sipTransport.SendResponse(badReqResponse);
                    }
                    else if (registerRequest.Header.Contact == null || registerRequest.Header.Contact.Count == 0)
                    {
                        Logger.Logger.Debug("Bad register request, no Contact header from " + remoteEndPoint + ".");
                        SIPResponse badReqResponse = SIPTransport.GetResponse(registerRequest,
                                                                              SIPResponseStatusCodesEnum.BadRequest, "Missing Contact header");
                        _sipTransport.SendResponse(badReqResponse);
                    }
                    else if (requestedExpiry > 0 && requestedExpiry < m_minimumBindingExpiry)
                    {
                        Logger.Logger.Debug("Bad register request, no expiry of " + requestedExpiry +
                                            " to small from " +
                                            remoteEndPoint + ".");
                        SIPResponse tooFrequentResponse = GetErrorResponse(registerRequest,
                                                                           SIPResponseStatusCodesEnum.IntervalTooBrief, null);
                        tooFrequentResponse.Header.MinExpires = m_minimumBindingExpiry;
                        _sipTransport.SendResponse(tooFrequentResponse);
                    }
                    else
                    {
                        if (m_registerQueue.Count < MAX_REGISTER_QUEUE_SIZE)
                        {
                            var registrarTransaction = _sipTransport.CreateNonInviteTransaction(registerRequest,
                                                                                                remoteEndPoint, localSIPEndPoint, null);
                            lock (m_registerQueue)
                            {
                                m_registerQueue.Enqueue(registrarTransaction);
                            }
                        }
                        else
                        {
                            Logger.Logger.Error("Register queue exceeded max queue size " + MAX_REGISTER_QUEUE_SIZE +
                                                ", overloaded response sent.");
                            SIPResponse overloadedResponse = SIPTransport.GetResponse(registerRequest,
                                                                                      SIPResponseStatusCodesEnum.TemporarilyUnavailable,
                                                                                      "Registrar overloaded, please try again shortly");
                            _sipTransport.SendResponse(overloadedResponse);
                        }

                        m_registerARE.Set();
                    }
                }
            }
            catch (Exception excp)
            {
                Logger.Logger.Error("Exception AddRegisterRequest (" + remoteEndPoint.ToString() + "). ->" +
                                    excp.Message);
            }
        }