public void EndGameSession() { try { var resp = NetworkActions.POST(Server + "/task/game/finish", "", Auth_key); var sr = new StreamReader(resp.GetResponseStream()); var content = sr.ReadToEnd(); if (resp.StatusCode == HttpStatusCode.OK) { Console.WriteLine(content); } } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message); } }
public void DeliveryFoundWords(List <string> foundWords) { var postData = MakemakeDataForPost(foundWords); try { var resp = NetworkActions.POST(Server + "/task/words/", postData, Auth_key); var sr = new StreamReader(resp.GetResponseStream()); var content = sr.ReadToEnd(); if (resp.StatusCode == HttpStatusCode.OK) { Console.WriteLine(content); } } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message); } }
public string Move(TypeMove typeMove) { var partToroid = ""; try { var resp = NetworkActions.POST(Server + "/task/move/" + typeMove.ToString(), "", Auth_key); var sr = new StreamReader(resp.GetResponseStream()); var content = sr.ReadToEnd(); if (resp.StatusCode == HttpStatusCode.OK) { partToroid = content; } } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message); } return(partToroid); }
public string InitializingGamingSession() { var content = ""; try { var resp = NetworkActions.POST(Server + "/task/game/start", "", Auth_key); var sr = new StreamReader(resp.GetResponseStream()); content = sr.ReadToEnd(); if (resp.StatusCode == HttpStatusCode.OK) { TimeToFinish = int.Parse(resp.Headers.Get("Expires")); } } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message); RegistrationBot(); } return(content); }
public GameStatistics GetStats() { GameStatistics gameStat = null; try { var resp = NetworkActions.GET(Server + "/task/game/stats", Auth_key); var sr = new StreamReader(resp.GetResponseStream()); var content = sr.ReadToEnd(); if (resp.StatusCode == HttpStatusCode.OK) { var parsed = JsonConvert.DeserializeObject <Dictionary <string, int> >(content); gameStat = new GameStatistics(parsed["points"], parsed["moves"], parsed["words"]); Console.WriteLine(content); } } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message); } return(gameStat); }