/// <summary>
        /// Override process method.
        /// </summary>
        public override void Process()
        {
            bool      unhandledExceptionDetected = true;
            Exception exceptionCaught            = null;

            try
            {
                RealTimeEndpoint   innerEndpoint = this.LocalEndpoint.InnerEndpoint;
                SendMessageOptions options       = new SendMessageOptions();
                options.ContentDescription = ContactCenterDiscoveryAsyncResult.GetDiscoveryRequestContentDescription();
                RealTimeAddress targetAddress = new RealTimeAddress(this.TargetUri);
                innerEndpoint.BeginSendMessage(MessageType.Service, targetAddress, options, this.ServiceRequestCompleted, innerEndpoint /*state*/);
                unhandledExceptionDetected = false;
            }
            catch (ArgumentException ae)
            {
                Helper.Logger.Error("Exception = {0}", EventLogger.ToString(ae));
                exceptionCaught            = ae;
                unhandledExceptionDetected = false;
            }
            catch (InvalidOperationException ioe)
            {
                Helper.Logger.Info("Exception = {0}", EventLogger.ToString(ioe));
                exceptionCaught            = ioe;
                unhandledExceptionDetected = false;
            }
            catch (RealTimeException rte)
            {
                Helper.Logger.Info("Exception = {0}", EventLogger.ToString(rte));
                exceptionCaught            = rte;
                unhandledExceptionDetected = false;
            }
            finally
            {
                if (unhandledExceptionDetected)
                {
                    exceptionCaught = new Exception("Unhandled exception");
                    Helper.Logger.Info("Exception = {0}", EventLogger.ToString(exceptionCaught));
                }

                if (exceptionCaught != null)
                {
                    this.Complete(exceptionCaught);
                }
            }
        }
        internal bool SendOptions(string targetUri)
        {
            int             num             = 0;
            SipResponseData sipResponseData = null;

            this.Error = null;
            this.MsDiagnosticsHeaderValue = string.Empty;
            try
            {
                RealTimeEndpoint innerEndpoint = this.endPoint.InnerEndpoint;
                new SendMessageOptions();
                sipResponseData = innerEndpoint.EndSendMessage(innerEndpoint.BeginSendMessage(2, new RealTimeAddress(targetUri), null, null, null, null));
            }
            catch (Exception ex)
            {
                this.ErrorTrace("SendOptions. Error: {0}", new object[]
                {
                    ex
                });
                this.Error = new TUC_SipOptionsError(targetUri, ex.Message, ex);
                FailureResponseException ex2 = ex as FailureResponseException;
                if (ex2 != null)
                {
                    this.DebugTrace("SendOptions. Known FailureResponseException. Getting response data.", new object[0]);
                    sipResponseData = ex2.ResponseData;
                }
                else
                {
                    if (!(ex is RealTimeException) && !(ex is InvalidOperationException) && !(ex is ArgumentException))
                    {
                        throw ex;
                    }
                    this.DebugTrace("SendOptions. Known exception {0}", new object[]
                    {
                        ex.GetType()
                    });
                }
            }
            if (sipResponseData != null)
            {
                num = sipResponseData.ResponseCode;
                SignalingHeader signalingHeader = sipResponseData.SignalingHeaders.FirstOrDefault((SignalingHeader x) => x.Name.Equals("ms-diagnostics", StringComparison.OrdinalIgnoreCase));
                this.MsDiagnosticsHeaderValue = ((signalingHeader != null) ? signalingHeader.GetValue() : string.Empty);
            }
            return(num == 200);
        }
        /// <summary>
        /// Callback method for service completed.
        /// </summary>
        /// <param name="asyncResult">Async result.</param>
        private void ServiceRequestCompleted(IAsyncResult asyncResult)
        {
            RealTimeEndpoint innerEndpoint = asyncResult.AsyncState as RealTimeEndpoint;

            Debug.Assert(null != innerEndpoint, "Inner endpoint is null");
            bool      unhandledExceptionDetected = true;
            Exception exceptionCaught            = null;
            ContactCenterInformation result      = null;

            try
            {
                SipResponseData serviceResponse = innerEndpoint.EndSendMessage(asyncResult);
                byte[]          responseBody    = serviceResponse.GetMessageBody();

                if (responseBody != null)
                {
                    result = ContactCenterDiscoveryAsyncResult.DeserializeResponseData(responseBody);
                }

                if (result == null)
                {
                    //Deserialziation failed.
                    exceptionCaught = new XmlException("Deserialization of queue uri mapping failed");
                }
                unhandledExceptionDetected = false;
            }
            catch (XmlException xe)
            {
                exceptionCaught            = xe;
                unhandledExceptionDetected = false;
            }
            catch (ArgumentException ae)
            {
                exceptionCaught            = ae;
                unhandledExceptionDetected = false;
            }
            catch (RealTimeException rte)
            {
                exceptionCaught            = rte;
                unhandledExceptionDetected = false;
            }
            finally
            {
                if (unhandledExceptionDetected)
                {
                    exceptionCaught = new Exception("Unhandled exception");
                    Helper.Logger.Info("Exception = {0}", EventLogger.ToString(exceptionCaught));
                }

                if (exceptionCaught != null)
                {
                    Helper.Logger.Error("Exception = {0}", EventLogger.ToString(exceptionCaught));
                    this.Complete(exceptionCaught);
                }
                else
                {
                    Debug.Assert(null != result, "If no exception occured, we expect a valid result");
                    this.Complete(result);
                }
            }
        }