/// <summary> /// Dispose method. /// </summary> /// <param name="disposing">Disposing flag.</param> protected virtual void Dispose(bool disposing) { if (!m_isDisposed) { if (disposing) { ContactCenterWcfServiceClient wcfClient = this.WcfClient; if (wcfClient != null) { this.UnregisterEventHandlers(wcfClient); CommunicationState commState = wcfClient.State; if (commState == CommunicationState.Faulted) { wcfClient.Abort(); } else { wcfClient.CloseAsync(); } } m_contactCenterWcfServiceClient = null; m_isDisposed = true; } } }
/// <summary> /// Unregisters all event handlers. /// </summary> private void UnregisterEventHandlers(ContactCenterWcfServiceClient wcfClient) { if (wcfClient != null) { wcfClient.ConversationTerminatedReceived -= this.ConversationTerminatedReceived; wcfClient.InstantMessageReceivedReceived -= this.InstantMessageReceivedReceived; wcfClient.RemoteComposingStatusReceived -= this.RemoteComposingStatusReceived; } }
/// <summary> /// Creates a new contact center service based on the endpoint uri. /// </summary> /// <param name="endpointUri">Endpoint uri. Cannot be null or empty.</param> public ContactCenterService(string endpointUri) { if (String.IsNullOrEmpty(endpointUri)) { throw new ArgumentException("Endpoint uri is not valid", endpointUri); } EndpointAddress address = new EndpointAddress(endpointUri); PollingDuplexHttpBinding binding = new PollingDuplexHttpBinding(); m_contactCenterWcfServiceClient = new ContactCenterWcfServiceClient(binding, address); this.RegisterEventHandlers(this.WcfClient); }