/// <summary> /// Begin terminate method. /// </summary> /// <param name="terminationConversationRequest">Termination request.</param> /// <param name="asyncCallback">callback.</param> /// <param name="state">State.</param> /// <returns>IAsync result.</returns> public IAsyncResult BeginTerminate(TerminateConversationRequest terminationConversationRequest, AsyncCallback asyncCallback, object state) { //Create a new async result. TerminateConversationAsyncResult asyncResult = new TerminateConversationAsyncResult(terminationConversationRequest, this, asyncCallback, state); asyncResult.Process(); return(asyncResult); }
/// <summary> /// Constructor to create new TerminateConversationAsyncResult. /// </summary> /// <param name="request">Terminate conversation request. cannot be null.</param> /// <param name="webConversation">Web conversation to terminate. Cannot be null.</param> /// <param name="userCallback">User callback.</param> /// <param name="state">User state.</param> internal TerminateConversationAsyncResult(TerminateConversationRequest request, WebConversation webConversation, AsyncCallback userCallback, object state) : base(userCallback, state) { Debug.Assert(null != webConversation, "Web conversation is null"); Debug.Assert(null != request, "Request is null"); m_webConversation = webConversation; m_terminateConversationRequest = request; }
/// <summary> /// Initiates a conversation termination operation. /// </summary> /// <param name="webConversation">Web conversation.</param> /// <param name="asyncCallback">Async callback.</param> /// <param name="state">State.</param> /// <returns>Async result reference</returns> public IAsyncResult BeginTerminateConversation(WebConversation webConversation, AsyncCallback callback, object state) { //Create new request. if (webConversation == null) { throw new ArgumentNullException("webConversation", "Web conversation cannot be null"); } TerminateConversationRequest request = new TerminateConversationRequest(); request.RequestId = ContactCenterService.GenerateNewRequestId(); request.Conversation = webConversation; return(((IContactCenterWcfService)this.WcfClient).BeginTerminateConversation(request, callback, state)); }
/// <summary> /// Handle client channel closed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ChannelClosed(object sender, EventArgs e) { IContextChannel contextChannel = sender as IContextChannel; contextChannel.Faulted -= this.ChannelClosed; contextChannel.Closed -= this.ChannelClosed; TerminateConversationRequest request = new TerminateConversationRequest(); request.Conversation = this; request.RequestId = Guid.NewGuid().ToString(); this.BeginTerminate(request, this.ConversationTerminated, null); }
/// <summary> /// Method to start the work of retrieving new data. /// </summary> private void TerminateUnnecessaryConversations() { foreach (WebConversation webConversation in m_conversationManager.GetAllWebConversations()) { CommunicationState channelState = webConversation.ContextChannel.State; if (channelState != CommunicationState.Created && channelState != CommunicationState.Opened && channelState != CommunicationState.Opening) { //Create a new async result. TerminateConversationRequest convRequest = new TerminateConversationRequest(); convRequest.Conversation = webConversation; convRequest.RequestId = Guid.NewGuid().ToString(); webConversation.BeginTerminate(convRequest, this.WebConversationTerminationCompleted, webConversation /*state*/); } } }
/// <summary> /// Constructor to create a new terminate conversation response. /// </summary> /// <param name="request">Original request.</param> public TerminateConversationResponse(TerminateConversationRequest request) : base(request) { }