Exemple #1
0
        public void registerAccount(Socket clientSocket)
        {
            string[] fields       = Message.Split('|');
            string   username     = fields[0];
            string   password     = fields[1];
            string   email        = fields[2];
            bool     usernameUsed = Singleton.Singleton.Instance.DatabaseConnection.isUsernameUsed(username);

            if (usernameUsed)
            {
                responseBack(clientSocket, GameProtocol.UsernameAlreadyUsedPacketID());
            }
            else
            {
                bool emailUsed = Singleton.Singleton.Instance.DatabaseConnection.isEmailUsed(email);
                if (emailUsed)
                {
                    responseBack(clientSocket, GameProtocol.EmailAlreadyUsedPacketID());
                }
                else
                {
                    bool done = Singleton.Singleton.Instance.DatabaseConnection.addUser(new User(0, username, password, email));

                    if (done)
                    {
                        responseBack(clientSocket, GameProtocol.SuccesCreateAccountPacketID());
                    }
                    else
                    {
                        responseBack(clientSocket, GameProtocol.FailedCreateAccountPacketID());
                    }
                }
            }
        }