Esempio n. 1
0
        public IActionResult Post([FromBody] TokenRequest parameters)
        {
            if (parameters == null || parameters.token == null)
            {
                return(BadRequest(new Response("Wrong parameters", null)));
            }

            string token = parameters.token;
            string error = "";

            if (!TokenManager.CheckUser(token))
            {
                error = ErrorTypes.UNAUTH_USER_ERROR.ToString();
            }

            Response resp;

            if (error == "")
            {
                LobbiesResponse lobbiesResp = Lobbies.getLobbiesResponse();
                resp = new Response(error, lobbiesResp);
            }
            else
            {
                resp = new Response(error, null);
            }

            IActionResult res = Ok(resp);

            return(res);
        }
Esempio n. 2
0
        public void LobbiesTest()
        {
            Lobby l = new Lobby("Lobby");

            l.ConnectPlayer(new ProjectAstolfo.Model.Player("PlayerToken", "s"));
            Lobbies.AddLobby(l);
            var x = Lobbies.getLobbiesResponse();

            Assert.AreEqual(x.lobbyResponses[0].name, "Lobby");
        }