Ejemplo n.º 1
0
            /// <summary>
            /// To complete the start up operation it is essential that the match maker be started correctly.
            /// </summary>
            /// <param name="ar"></param>
            private void OnMatchMakerStartUpComplete(IAsyncResult ar)
            {
                AcdAgentMatchMaker matchMaker = ar.AsyncState as AcdAgentMatchMaker;

                try
                {
                    matchMaker.EndStartup(ar);

                    _acdPlatform._platform.UnregisterForApplicationEndpointSettings(OnMatchMakerFound);
                    _acdPlatform.RegisterForPlatformAutoProvisioningEvents();

                    _acdPlatform.UpdateAcdPlatformState(AcdPlatformState.Started);
                    this.SetAsCompleted(null, false);
                }
                catch (RealTimeException ex)
                {
                    _acdPlatform._logger.Log("AcdPlatform could not start the match maker", ex);
                    _acdPlatform.BeginShutdown(_acdPlatform.OnPlatformShutdownComplete, null);
                    this.SetAsCompleted(ex, false);
                    return;
                }
                catch (InvalidOperationException ivoex)
                {
                    _acdPlatform._logger.Log("AcdPlatform could not start the match maker", ivoex);
                    _acdPlatform.BeginShutdown(_acdPlatform.OnPlatformShutdownComplete, null);
                    this.SetAsCompleted(new OperationFailureException("AcdPlatform could not start the match maker", ivoex), false);
                    return;
                }
            }
Ejemplo n.º 2
0
            /// <summary>
            /// matchMakerStateChanged is the event handler that takes care of detecting when the matchmaker
            /// gets removed from the data base. When this happens, there is no other option but to shutdown the
            /// platform
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="args"></param>
            private void matchMakerStateChanged(object sender, LocalEndpointStateChangedEventArgs args)
            {
                AcdPlatform platform = _matchMaker._platform;
                AcdLogger   logger   = _matchMaker._logger;

                if (args.Reason == LocalEndpointStateTransitionReason.OwnerDisabledOrRemoved)
                {
                    if (null != platform)
                    {
                        platform.BeginShutdown(ar => { platform.EndShutdown(ar); }, null);

                        if (null != logger)
                        {
                            logger.Log("AcdAgentMatchMaker: Contact has been moved or removed, shutting down the application.");
                        }
                    }
                    else
                    {
                        if (null != logger)
                        {
                            _matchMaker._logger.Log("AcdAgentMatchMaker: Contact has been moved or removed, but the platform is null. Cannot shut down the application.");
                        }
                    }
                }
            }