public string Ready(long?timeLeft) { if (timeLeft == null) { return("{\"ResponseCode\":\"" + ResponseCode.ERROR + "\", \"Message\":\"Missing 'timeLeft.'\"}"); } string lanID = Authenticator.GetLanID(); if (lanID == null) { EventLogger.Log(EventCode.LOGIN_FAIL, "/ready"); return("{\"ResponseCode\":\"" + ResponseCode.ERROR + "\", \"Message\":\"Fail to login. Try again using Internet Explorer.\"}"); } Player player = Gaming.RetrievePlayer(lanID); bool isNewGame = false; Game game = Gaming.ResumeGame(player, CURRENT_QUESTION_SET_ID, ref isNewGame); if (game.IsGameEnded) { // Users are not supposed to reach this code.. return("{\"ResponseCode\":\"" + ResponseCode.GAMEOVER + "\", \"Message\":\"TIME OUT !\"}"); } else { // NOTE: Record the time-left that user reported. Session session = Gaming.GetCurrentSessionForReady(game, (long)timeLeft); // This means no more question if (session == null) { EventLogger.Log(EventCode.READY_NO_QUESTION, game.GameID + ""); Gaming.EndTheGame(game); return("{\"ResponseCode\":\"" + ResponseCode.GAMEOVER + "\", \"Message\":\"You answered all question.\"}"); } // TODO: Total time too much? time stamp mistmatch ? if (false) { EventLogger.Log(EventCode.READY_TIME_ANOMALY, game.GameID + ",reason here"); } EventLogger.Log(EventCode.READY, session.SessionID + ""); Question question = Gaming.GetQuestion(session); string json = "{"; json += "\"ResponseCode\": \"" + ResponseCode.QUESTION + "\""; json += ",\"QuestionID\": " + question.QuestionID; json += ",\"Title\": \"" + question.TITLE + "\""; json += ",\"Picture\": \"" + question.Picture + "\""; json += ",\"Choice1\": \"" + question.Choice1 + "\""; json += ",\"Choice2\": \"" + question.Choice2 + "\""; json += ",\"Choice3\": \"" + question.Choice3 + "\""; json += ",\"Choice4\": \"" + question.Choice4 + "\""; json += "}"; return(json); } }