コード例 #1
0
        private static void RegisterAccount(JamServerConnection serverConnection, JamPacket packet)
        {
            RegisterAccountRequest register = new RegisterAccountRequest(packet.Data, serverConnection.Serializer);

            RegisterAccountResponse response;

            try
            {
                Account createdAccount = AccountFactory.Generate(register.Username, register.Password, Program.Server.HashFactory, true);
                response = new RegisterAccountResponse(RegisterAccountResponse.AccountRegistrationResult.Good, createdAccount, serverConnection.Serializer);

                Console.WriteLine("Registered new Account: {0} - {1}", createdAccount.AccountID, createdAccount.Username);
            }
            catch (DbUpdateException)
            {
                response = new RegisterAccountResponse(RegisterAccountResponse.AccountRegistrationResult.Bad, null, serverConnection.Serializer);
            }
            catch (EntityException)
            {
                serverConnection.Server.Dispose();
                return;
            }

            JamPacket responsePacket = new JamPacket(Guid.Empty, Guid.Empty, RegisterAccountResponse.DATA_TYPE, response.GetBytes());

            serverConnection.Send(responsePacket);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: TheJimmyBlaze/JamLib
        private static void AttemptCreateRootAccount(IHashFactory hashFactory)
        {
            Console.WriteLine("Enter root username:"******"Enter root password:"******"Root account created successfully.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Root Account ERROR: {0}", ex);
                AttemptCreateRootAccount(hashFactory);
            }
        }