private static string[] readData() { string[] data = null; try { System.Net.ServicePointManager.ServerCertificateValidationCallback = Common.Util.BaseHelper.RemoteCertificateValidationCallback; using (System.Net.WebClient client = new Common.Util.CTWebClient()) { string content = client.DownloadString(Util.Constants.ASSET_UPDATE_CHECK_URL); foreach (string line in Common.Util.BaseHelper.SplitStringToLines(content).Where(line => line.CTStartsWith(EditorConstants.ASSET_UID.ToString()))) { data = line.Split(splitChar, System.StringSplitOptions.RemoveEmptyEntries); if (data.Length >= 3) { //valid record? break; } data = null; } } } catch (System.Exception ex) { Debug.LogError($"Could not load update file: {ex}"); } return(data); }
private static void post(string postData) { byte[] data = new System.Text.ASCIIEncoding().GetBytes(postData); try { System.Net.ServicePointManager.ServerCertificateValidationCallback = Util.BaseHelper.RemoteCertificateValidationCallback; using (System.Net.WebClient client = new Common.Util.CTWebClient()) { client.Headers[System.Net.HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; client.Headers[System.Net.HttpRequestHeader.UserAgent] = "Mozilla/5.0 (" + userAgent() + ")"; client.UploadData("tcelloc/moc.scitylana-elgoog.www//:sptth".CTReverse(), data); if (Util.BaseConstants.DEV_DEBUG) { Debug.Log("Data uploaded: " + postData); } } } catch (System.Exception ex) { if (Util.BaseConstants.DEV_DEBUG) { Debug.LogError("Could not upload GA-data: " + System.Environment.NewLine + ex); } } }
private static string[] readData() { string[] data = null; try { System.Net.ServicePointManager.ServerCertificateValidationCallback = Util.Helper.RemoteCertificateValidationCallback; using (System.Net.WebClient client = new Common.Util.CTWebClient()) { string content = client.DownloadString(Util.Constants.ASSET_UPDATE_CHECK_URL); foreach (string line in Util.Helper.SplitStringToLines(content)) { //Debug.Log("Line: " + line); if (line.StartsWith(EditorConstants.ASSET_UID.ToString())) { data = line.Split(splitChar, System.StringSplitOptions.RemoveEmptyEntries); //Debug.Log("data: " + data.CTDump()); if (data != null && data.Length >= 3) { //valid record? break; } else { //Debug.LogWarning("invalid data: " + data.Length); data = null; } } } } } catch (System.Exception ex) { Debug.LogError("Could not load update file: " + System.Environment.NewLine + ex); } return(data); }
private void getVoicesInEditor() { System.Collections.Generic.List <string[]> serverVoicesResponse = new System.Collections.Generic.List <string[]>(); if (!Util.Helper.isInternetAvailable) { string errorMessage = "Internet is not available - can't use MaryTTS right now!"; Debug.LogError(errorMessage); } else { try { System.Net.ServicePointManager.ServerCertificateValidationCallback = Util.Helper.RemoteCertificateValidationCallback; using (System.Net.WebClient client = new Common.Util.CTWebClient()) { if (headers != null) { foreach (System.Collections.Generic.KeyValuePair <string, string> kvp in headers) { client.Headers.Add(kvp.Key, kvp.Value); } } using (System.IO.Stream stream = client.OpenRead(uri + "/voices")) { using (System.IO.StreamReader reader = new System.IO.StreamReader(stream)) { string content = reader.ReadToEnd(); if (Util.Config.DEBUG) { Debug.Log(content); } string[] rawVoices = content.Split('\n'); foreach (string rawVoice in rawVoices) { try { if (!string.IsNullOrEmpty(rawVoice)) { string[] newVoice = { rawVoice.Split(' ') [0], rawVoice.Split(' ') [1], rawVoice.Split(' ') [2] }; serverVoicesResponse.Add(newVoice); } } catch (System.Exception ex) { Debug.LogWarning("Problem preparing voice: " + rawVoice + " - " + ex); } } System.Collections.Generic.List <Model.Voice> voices = new System.Collections.Generic.List <Model.Voice>(40); foreach (string[] voice in serverVoicesResponse) { voices.Add(new Model.Voice(voice[0], "MaryTTS voice: " + voice[0], Util.Helper.StringToGender(voice[2]), "unknown", voice[1])); } cachedVoices = voices.OrderBy(s => s.Name).ToList(); if (Util.Constants.DEV_DEBUG) { Debug.Log("Voices read: " + cachedVoices.CTDump()); } } } } } catch (System.Exception ex) { Debug.LogError(ex); } onVoicesReady(); } }