internal void Process() { //Draining is done _acdPortal.UpdatePortalState(PortalState.Terminating); _acdPortal._endpoint.StateChanged -= _acdPortal.OnPortalEndpointStateChanged; //Dispose the TimerWheel _acdPortal.TmrWheel.Dispose(); //unregister the events _acdPortal._endpoint.UnregisterForIncomingCall <InstantMessagingCall>(_acdPortal.HandleInstantMessagingCallReceived); _acdPortal._endpoint.UnregisterForIncomingCall <AudioVideoCall>(_acdPortal.HandleAudioVideoCallReceived); _acdPortal._endpoint.UnregisterForIncomingCall <ApplicationSharingCall>(_acdPortal.HandleApplicationSharingCallReceived); //Terminate the endpoint _acdPortal._endpoint.BeginTerminate(delegate(IAsyncResult ar) { _acdPortal._endpoint.EndTerminate(ar); lock (_acdPortal._syncRoot) { _acdPortal.UpdatePortalState(PortalState.Terminated); } //complete the current shutdown operation this.SetAsCompleted(null, false); //if there are other pending shutdown operations in the queue, complete them foreach (ShutdownAsyncResult result in _acdPortal._listOfShutdownAsyncResults) { result.SetAsCompleted(null, false); } }, null); }
/// <summary> /// Finish the endpoint establishment, and notify the AgentManager to start listening for /// presence notifications for the agents in the system. /// </summary> private void OnEndpointEstablishComplete(IAsyncResult ar) { try { _acdPortal._endpoint.EndEstablish(ar); _acdPortal._acdPlatform.AnonymousSubscriberUriChanged += _acdPortal.OnAnonymousSubscriberUriChanged; _acdPortal.UpdatePortalState(PortalState.Started); _acdPortal.PublishPresenceToWebCustomers(); _acdPortal._averageQueueTimeRefreshTimer = new TimerItem(_acdPortal._wheel, new TimeSpan(0, 0, 0, 15)); _acdPortal._averageQueueTimeRefreshTimer.Expired += _acdPortal.OnAverageQueueTimeRefreshNeeded; _acdPortal._averageQueueTimeRefreshTimer.Start(); this.SetAsCompleted(null, false); } catch (RealTimeException ex) { _acdPortal._logger.Log("AcdPortal failed establishing the endpoint", ex); _acdPortal.BeginShutdown(OnShutdownComplete, null); this.SetAsCompleted(ex, false); return; } }