Beispiel #1
0
        private static string handleCreateSessionRequest(NameValueCollection requestData)
        {
            var responseData      = HttpUtility.ParseQueryString("");
            var validLoginAccount = LoginAccountList.GetValidLogin(requestData["username"], requestData["password"]);

            if (validLoginAccount != null)
            {
                Session newSession = new Session(requestData["username"], DateTime.Now.AddHours(23), Convert.ToBase64String(Guid.NewGuid().ToByteArray()));
                if (SessionList.TryAddSession(newSession))
                {
                    LoggedInUserList.AddOrUpdateLoggedInUser(new LoggedInUser(newSession.LoginUsername, validLoginAccount.Playername, ""));
                    responseData.Add("result", "success");
                    responseData.Add("token", newSession.Token);
                    responseData.Add("playername", validLoginAccount.Playername);
                }
                else
                {
                    responseData.Add("result", "fail");
                }
            }
            else
            {
                responseData.Add("result", "fail");
            }
            return(responseData.ToString());
        }
Beispiel #2
0
        private static string handleCreateGameRequest(NameValueCollection requestData)
        {
            var responseData = HttpUtility.ParseQueryString("");

            if (SessionList.IsValidSession(requestData["token"]) &&
                CreatedGameList.TryAddCreatedGame(new CreatedGame(requestData["gamename"], (requestData["usepincode"] == "1")?true:false, requestData["pincode"])))
            {
                responseData.Add("result", "success");
            }
            else
            {
                responseData.Add("result", "fail");
            }
            return(responseData.ToString());
        }
Beispiel #3
0
        private static string handleRemoveSessionRequest(NameValueCollection requestData)
        {
            var responseData = HttpUtility.ParseQueryString("");

            if (SessionList.TryRemoveSession(requestData["token"], requestData["username"]))
            {
                LoggedInUserList.RemoveLoggedInUser(requestData["username"]);
                responseData.Add("result", "success");
            }
            else
            {
                responseData.Add("result", "fail");
            }
            return(responseData.ToString());
        }
Beispiel #4
0
        private static string handleJoinGameRequest(NameValueCollection requestData)
        {
            var responseData = HttpUtility.ParseQueryString("");
            var session      = SessionList.GetValidSession(requestData["token"]);
            var createdGame  = CreatedGameList.GetCreatedGame(requestData["gamename"]);

            if (session != null && createdGame != null)
            {
                if (LoggedInUserList.UpdateCurrentGamenameOnLoggedInUser(session.LoginUsername, requestData["gamename"]))
                {
                    responseData.Add("result", "success");
                }
                else
                {
                    responseData.Add("result", "fail");
                }
            }
            else
            {
                responseData.Add("result", "fail");
            }
            return(responseData.ToString());
        }