private void MainWorkerFunc(object sender, DoWorkEventArgs e) { //Ротация в цикле while (true) { //Если источник не загружен if (!IsSourceLoaded) { Profile currentProfile = ProfileManager.CurrentProfile; //Добавляем задачу загрузки TaskManager.AquireLock(LoadingTask); //Показываем анимацию загрузки IsLoadingAnim(true, true); IsStatic = false; IsErrorOccured = false; //Получаем информацию, необходимую для ротации GuildName = currentProfile.Rotation.Guild; TamerName = currentProfile.Rotation.Tamer; IConfiguration config = ConfigurationManager.GetConfiguration(currentProfile.GameModel); IWebProvider webProvider = config.CreateWebProvider(); IServersProvider serversProvider = config.ServersProvider; //Проверяем, доступен ли веб-профиль и необходимая информация IsStatic = webProvider == null || string.IsNullOrEmpty(GuildName); if (!IsStatic) { Server = serversProvider.GetServerById(currentProfile.Rotation.ServerId); //Регистрируем ивенты загрузки webProvider.StatusChanged += EventProxy.OnStatusChanged; webProvider.DownloadCompleted += EventProxy.OnDownloadCompleted; //Получаем информацию о списках гильдии webProvider.GetActualGuild(Server, GuildName, false, currentProfile.Rotation.UpdateInterval + 1); //Убираем обработку ивентов webProvider.DownloadCompleted -= EventProxy.OnDownloadCompleted; webProvider.StatusChanged -= EventProxy.OnStatusChanged; } //Проверяем не произошла ли ошибка if (!IsErrorOccured) { //Закрываем анимацию, устанавливаем флаг загрузки IsLoadingAnim(false); } TaskManager.ReleaseLock(LoadingTask); IsSourceLoaded = true; } if (!IsErrorOccured && IsSourceLoaded) { UpdateModel(); System.Threading.Thread.Sleep(ROTATION_INTERVAL); } } }
public MasterServerHttpServer(ITcpListenerWrapper tcpListener, IStreamFactory streamFactory, IServersProvider serversProvider, IHttpProcessorFactory httpProcessorFactory, IEncryptor encryptor, IStripMessenger stripMessenger) : base(tcpListener, streamFactory, httpProcessorFactory) { this.serversProvider = serversProvider; this.encryptor = encryptor; this.stripMessenger = stripMessenger; }
protected override void OnProfileChanged(object sender, BaseEventArgs e) { IConfiguration currentConfiguration = ConfigurationManager.GetConfiguration(ProfileManager.CurrentProfile.GameModel); serversProvider = currentConfiguration.ServersProvider; webProvider = currentConfiguration.CreateWebProvider(); GuildInfoModel.UnLoadData(); TDBlock_.ClearAll(); IsDetailedCheckbox.IsChecked = false; // use lazy ServerList initialization to prevent first long EF6 database // init causes the long app start time if (IsPageActivated) { LoadServerList(); } }
private const int serversRefreshInterval = 5; // [sec] public MainForm(IServersProvider serversProvider, IPlayersProvider playersProvider, IMongoDbProvider dbProvider, HttpServer masterServerHttpServer, IStripMessenger stripMessenger) { this.serversProvider = serversProvider; this.playersProvider = playersProvider; this.masterServerHttpServer = masterServerHttpServer; this.stripMessenger = stripMessenger; this.dbProvider = dbProvider; InitializeComponent(); this.serversProvider.OnUpdateServers += UpdateServersInvoker; this.stripMessenger.OnNewMessageReceived += OnNewMessageReceived; ConnectToMongo(); }