private void Update() { if ((this.wwwLoader != null) && this.wwwLoader.IsDone) { if (!string.IsNullOrEmpty(this.wwwLoader.Error)) { if (WWWLoader.GetResponseCode(this.wwwLoader.WWW) >= 400) { this.HandleError <TechnicalWorkEvent>(); } else { this.HandleError <NoServerConnectionEvent>($"Configuration loading was failed. URL: {this.wwwLoader.URL}, Error: {this.wwwLoader.Error}"); } } else if ((this.wwwLoader.Bytes == null) || (this.wwwLoader.Bytes.Length == 0)) { this.HandleError <GameDataLoadErrorEvent>("Empty server state data. URL: " + this.wwwLoader.URL); } else { string data = string.Empty; try { data = Encoding.UTF8.GetString(this.wwwLoader.Bytes); StateConfiguration configuration = yamlService.Load <StateConfiguration>(data); this.state = configuration.State; if (this.state != 0) { this.HandleError <TechnicalWorkEvent>(); } } catch (Exception exception) { this.HandleError <GameDataLoadErrorEvent>($"Invalid configuration data. URL: {this.wwwLoader.URL}, Error: {exception.Message}, Data: {data}"); return; } this.DisposeWWWLoader(); base.Complete(); } } }
private void Update() { if ((this.wwwLoader != null) && this.wwwLoader.IsDone) { if (!string.IsNullOrEmpty(this.wwwLoader.Error)) { if (WWWLoader.GetResponseCode(this.wwwLoader.WWW) >= 400) { this.HandleError <TechnicalWorkEvent>(); } else { this.HandleError <NoServerConnectionEvent>($"Initial config loading was failed. URL: {this.wwwLoader.URL}, Error: {this.wwwLoader.Error}"); } } else if ((this.wwwLoader.Bytes == null) || (this.wwwLoader.Bytes.Length == 0)) { this.HandleError <GameDataLoadErrorEvent>("Initial config is empty. URL: " + this.wwwLoader.URL); } else { try { using (MemoryStream stream = new MemoryStream(this.wwwLoader.Bytes)) { StreamReader reader = new StreamReader(stream); InitConfiguration.Config = yamlService.Load <InitConfiguration>(reader); } } catch (Exception exception) { this.HandleError <GameDataLoadErrorEvent>($"Invalid initial config. URL: {this.wwwLoader.URL}, Error: {exception.Message}", exception); return; } this.DisposeWWWLoader(); base.Complete(); } } }