Пример #1
0
        public static void checkUser()
        {
            string check  = "check";
            string getUrl = KaroRequest.KaroUrl(check, check);

            KaroRequest.KaroGetRequest(getUrl);
        }
Пример #2
0
        public static void login()
        {
            // Testoutput for testing Cookie Object
            Console.WriteLine("");
            Console.WriteLine("Print Cookie Data from login-method out of KaroKeks Object before login post request:");
            Console.WriteLine(KaroKeks.Name);
            Console.WriteLine(KaroKeks.Domain);
            Console.WriteLine("");

            // create PostUrl
            string param1  = "login";
            string login   = "******";
            string postUrl = KaroRequest.KaroUrl(param1, login);

            Console.WriteLine(postUrl);
            // get user login data
            Console.Write("login: "******"pw: ";
            string pw     = getPasswordFromConsole(msg);
            string userpw = pw.ToString();

            // output for debug
            //Console.WriteLine(userpw);

            //Console.Write("pw: ");
            //string userpw = Console.ReadLine();

            //generate login dataobject
            UserLogin loginData = new UserLogin
            {
                login    = userlogin,
                password = userpw
            };

            // create CookieContainer to store cookies
            //CookieContainer cookieContainer = new CookieContainer();

            // convert loginData to string for passing to KaroPostRequest
            var    postData      = JsonConvert.SerializeObject(loginData);
            string loginResponse = KaroRequest.KaroPostRequest(postUrl, postData);

            Console.WriteLine(loginResponse);
            Console.WriteLine("");
            Console.WriteLine("Print Cookie Data from login-method out of KaroKeks Object after login post request:");
            Console.WriteLine(KaroKeks.Name);
            Console.WriteLine(KaroKeks.Domain);
            Console.WriteLine("");


            //Console.WriteLine(karoKeks.Name);
        }
Пример #3
0
        public static void logout()
        {
            Console.WriteLine("logging out ...");
            string param1         = "logout";
            string param2         = null;
            string logoutUrl      = KaroRequest.KaroUrl(param1, param2);
            string logoutResponse = KaroRequest.KaroGetRequest(logoutUrl);

            Console.WriteLine(logoutResponse);
            Console.WriteLine("");
            Console.WriteLine("logged out!");
            Console.WriteLine("");
        }
Пример #4
0
        public static void GetUser()
        {
            Console.WriteLine("userID: ");
            string id     = Console.ReadLine();
            string param1 = "userInfo";
            string url    = KaroRequest.KaroUrl(param1, id);

            Console.WriteLine(url);
            string userJson = KaroRequest.KaroGetRequest(url);

            Console.WriteLine(userJson);

            //pruefung, ob user gefunden wurde, da sonst kein Json-String zur konvertierung vorhanden
            if (userJson != "kein user gefunden!")
            {
                User u = JsonConvert.DeserializeObject <User>(userJson);
                Console.WriteLine(u.Id);
                Console.WriteLine(u.Login);
                Console.WriteLine(u.Color);
                Console.WriteLine(u.LastVisit);
                Console.WriteLine(u.Signup);
                Console.WriteLine(u.Dran);
                Console.WriteLine(u.ActiveGames);
                Console.WriteLine(u.AcceptsDayGames);
                Console.WriteLine(u.AcceptsNightGames);
                Console.WriteLine(u.MaxGames);
                Console.WriteLine(u.Sound);
                Console.WriteLine(u.Soundfile);
                Console.WriteLine(u.Size);
                Console.WriteLine(u.Border);
                Console.WriteLine(u.Desperate);
                Console.WriteLine(u.BirthdayToday);
                Console.WriteLine(u.KarodayToday);
                Console.WriteLine(u.Theme);
                Console.WriteLine(u.Bot);
                Console.WriteLine(u.Gamesort);
            }
        }
Пример #5
0
        public static void GetGame()
        {
            Console.WriteLine("GID: ");
            string gid    = Console.ReadLine();
            string param1 = "gameInfo";
            string url    = KaroRequest.KaroUrl(param1, gid);

            Console.WriteLine(url);
            string gameJson = KaroRequest.KaroGetRequest(url);

            Console.WriteLine(gameJson);
            Game g = JsonConvert.DeserializeObject <Game>(gameJson);

            Console.WriteLine(g.Id);
            Console.WriteLine(g.Name);
            Console.WriteLine(g.MapId);
            Console.WriteLine(g.Map.Name);
            Console.WriteLine(g.Map.Cps.Length);
            Console.WriteLine("Index 0: " + g.Map.Cps[0] + " | Index 1: " + g.Map.Cps[1] + " | Index 2: " + g.Map.Cps[2]);
            Console.WriteLine(g.Players.Length);
            Console.WriteLine(g.Players[0].Id);
            Console.WriteLine(g.Players[0].Name);
        }