public async Task <EnvResult> getEnvironment() { EnvResult envResult = new EnvResult(); using (HttpClient client = new HttpClient()) { client.BaseAddress = server; client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync("/api/environment/"); if (response.IsSuccessStatusCode) { string stringData = await response.Content.ReadAsStringAsync(); var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; envResult = JsonSerializer.Deserialize <EnvResult>(stringData, options); } } return(envResult); }
public EnvResult GetEnvironment() { Bme280ReadResult bme280Result = bme280.Read(); var humidity = bme280Result.Humidity?.Percent; var pressure = bme280Result.Pressure?.Hectopascals; var temperature = bme280Result.Temperature?.DegreesCelsius; EnvResult envResult = new EnvResult(); envResult.Temperature = temperature; envResult.Pressure = pressure; envResult.Humidity = humidity; return(envResult); }
public static ConfigData GetConfigData() { var ptgameConfig = LoadGameConfig(); #if UNITY_EDITOR int type = UnityEditor.EditorPrefs.GetInt(KeyPtgameServerenvType, 0); return(new ConfigData() { runtime = (PTRuntime)type, gameConfig = ptgameConfig }); #endif var configData = new ConfigData() { chanelName = ptgameConfig.chanelName, gameConfig = ptgameConfig }; if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork) { string parameters = string.Format("appname={0}&bundleid={1}&version={2}&buildnum={3}&custom={4}", Application.productName, Application.identifier, Application.version, PTUniInterface.GetBuildNumOrVersionCode(), ptgameConfig.custom); EnvResult envResult = null; RequestSync("http://10.1.223.240:5016/ptgameenv/GetEnvType?" + parameters, 1, (result, msg) => { if (result == 0) { Debug.LogError(msg + ">>>>"); envResult = JsonUtility.FromJson <EnvResult>(msg); if (envResult != null) { configData.runtime = (PTRuntime)envResult.type; } } }); } return(configData); }