예제 #1
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     string username;
        ///                     string password;
        ///                     string nickname;
        /// </summary>
        private static void HandleRegisterTry(ClientTCP client, byte[] data)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(data);
            buffer.ReadInteger();
            string username = buffer.ReadString();
            string password = buffer.ReadString();
            string nickname = buffer.ReadString();

            if (Global.data.LoginExist(username))
            {
                SendDataTCP.SendClientAlert(client, "Username already exist");
                return;
            }
            if (Global.data.NicknameExist(nickname))
            {
                SendDataTCP.SendClientAlert(client, "Nickname already exist");
                return;
            }
            Global.data.AddAccount(username, password, nickname);
            buffer.Dispose();
            SendDataTCP.SendRegisterOk(client);
        }