Exemplo n.º 1
0
        //get user data-------------------------------------------------
        public void GetUserData(List <string> login, string name)
        {
            bool isOnline = false;

            for (int i = 0; i < login.Count; i++)
            {
                if (login[i] == authorization)
                {
                    isOnline = true;
                }
            }
            if (!isOnline)
            {
                string data   = "\nuser is not logged in \n";
                string status = "404 Not found";
                string mime   = "text/plain";
                ServerResponse(status, mime, data);
                return;
            }
            int    lenght     = authorization.IndexOf("-mtcgToken");
            string playername = authorization.Substring(0, lenght);

            if (playername != name)
            {
                string data   = "\nyou cant get the info of another player \n";
                string status = "404 Not found";
                string mime   = "text/plain";
                ServerResponse(status, mime, data);
                return;
            }
            string playerdata = Database.selectPlayerData(name);

            if (playerdata == "")
            {
                string data   = "\nDatabase Error \n";
                string status = "404 Not found";
                string mime   = "text/plain";
                ServerResponse(status, mime, data);
                return;
            }
            else
            {
                string status = "200 Successs";
                string mime   = "text/plain";
                ServerResponse(status, mime, playerdata);
                return;
            }
        }