Exemplo n.º 1
0
        public void HandleDisconnectPacket(JObject json)
        {
            var authtoken = (string)json["AUTHTOKEN"];

            //Release the authtoken
            Authentication.ReleaseAuthToken(authtoken);

            //Send a response:
            var resp = new ResponsePacket(Statuscode.Status.Ok, "resp-dc");
            Send(resp);
        }
Exemplo n.º 2
0
        private void HandleLoginPacket(JObject json)
        {
            Console.WriteLine(Resources.ClientHandler_Debug_HandleLoginPacket);
            //Recieve the username and password from json.
            var username = json["username"].ToString();
            var password = json["password"].ToString();

            JObject returnJson;
            //Code to check User/pass here
            if (Authentication.Authenticate(username, password, this))
            {
                currentUser = _database.getUser(username);
                returnJson = new LoginResponsePacket(
                    Statuscode.Status.Ok,
                    Authentication.GetUser(username).AuthToken,
                    currentUser
                    ).ToJsonObject();

            }
            else //If the code reaches this point, the authentification has failed.
            {
                returnJson = new ResponsePacket(Statuscode.Status.InvalidUsernameOrPassword, "RESP-LOGIN");
            }

            //Send the result back to the client.
            Console.WriteLine(returnJson.ToString());
            Send(returnJson.ToString());
        }