/// <summary> /// Clears pending estalbish async result. /// </summary> internal void HandleEstablishmentCompletion(Exception e) { lock (this.syncRoot) { this.pendingEstablishAsyncResult = null; if (e != null) { this.BeginTerminate((asyncResult) => { this.EndTerminate(asyncResult); }, null); } } }
/// <summary> /// Establishes the call anchor for a customer session. /// </summary> /// <param name="callback"></param> /// <param name="state"></param> /// <returns></returns> public IAsyncResult BeginEstablish(RealTimeAddress helpdeskNumber, AsyncCallback callback, object state) { EstablishAsyncResult establishAsyncResult = null; if (helpdeskNumber == null) { throw new ArgumentNullException("helpdeskNumber"); } lock (this.syncRoot) { if (this.pendingEstablishAsyncResult != null) { throw new InvalidOperationException("Already a pending async result is in progress"); } if (this.customerRemoteParticipant == null) { throw new InvalidOperationException("Customer has already left the conversation"); } if (this.trustedConversation == null) { ConversationSettings settings = new ConversationSettings(ConversationPriority.Normal, "Dialout", "<" + this.CustomerUri + ">"); this.trustedConversation = new Conversation(this.customerConversation.Endpoint, settings); // Config change: We cannot impersonate with user endpoint. if (!Boolean.Parse(System.Configuration.ConfigurationManager.AppSettings["UseUserEndPoint"])) { this.trustedConversation.Impersonate(this.customerRemoteParticipant.Uri, this.customerRemoteParticipant.PhoneUri, this.customerRemoteParticipant.DisplayName); } this.RegisterTrustedConversationEventHandlers(this.trustedConversation); } establishAsyncResult = new EstablishAsyncResult(this, this.trustedConversation, this.customerConversation, helpdeskNumber, this.logger, callback, state); this.pendingEstablishAsyncResult = establishAsyncResult; } establishAsyncResult.Process(); return(establishAsyncResult); }
/// <summary> /// Ends the establishment process. /// </summary> /// <param name="asyncResult"></param> public void EndEstablish(IAsyncResult asyncResult) { EstablishAsyncResult establishAsyncResult = asyncResult as EstablishAsyncResult; establishAsyncResult.EndInvoke(); }