private static void FadeTimer_Elapsed(object sender, ElapsedEventArgs e) { if (fadeData == null) { return; } var jsonData = new EventUpdateJSON(); var dataContext = new EventUpdateDataJSON(); var value = fadeData.value; var port = fadeData.port; var game = fadeData.game; var Event = fadeData.Event; if (loops > 20) { loops = 0; FadeTimer.Stop(); UpdateEvent(port, game, Event, 40, new Dictionary <string, string>()); return; } dataContext.value = 40 - (loops * 2); jsonData.data = dataContext; jsonData.Event = Event; jsonData.game = game; var json = JsonConvert.SerializeObject(jsonData); var postData = new StringContent(json, Encoding.UTF8, "application/json"); client.PostAsync("http://127.0.0.1:" + port + "/game_event", postData); loops += 1; }
private static async void UpdateEvent(string port, string game, string Event, int value, Dictionary <string, string> frame) { var jsonData = new EventUpdateJSON(); var dataContext = new EventUpdateDataJSON(); dataContext.value = value; dataContext.frame = frame; jsonData.data = dataContext; jsonData.Event = Event; jsonData.game = game; var json = JsonConvert.SerializeObject(jsonData); var postData = new StringContent(json, Encoding.UTF8, "application/json"); var result = await client.PostAsync("http://127.0.0.1:" + port + "/game_event", postData); }