/*
         * In this class, there were many derived method that should be simpler, but no
         * as this is open the freedom to process more command if any appended change is
         * bound to set, and we will group it within this container, so a memory leak won't be a problem
         */

        public static void GenerateToken(Packet packet)
        {
            Packet sendPacket;

            try
            {
                ConsoleUtils.Print(string.Format("[{0}]'s Request: Requesting token exchange from server [{1}]", packet.ClientIP, packet.Username));
                Token newToken = PacketParser.GenerateToken();
                using (var dbCon = new MySQLDatabaseConnection(System.Net.IPAddress.Parse("127.0.0.1"), "exceeddb"))
                {
                    dbCon.Username = "******";
                    dbCon.Password = "******";
                    dbCon.Connect();
                    string brt     = dbCon.GetSqlDateTimeNow(2);
                    string command = string.Format("UPDATE `adminDB` SET `token`='{0}', `tokenExpired`='{1}' WHERE `username`='{2}'", newToken.GetString(),
                                                   brt, packet.Username);
                    dbCon.ExecuteCommand(command);
                    sendPacket = PacketParser.CreatePacketWithToken(ResponseEnum.ReceiveOK, newToken);
                    command    = string.Empty;
                    dbCon.Close();
                }
                packet.Stream.Write(sendPacket.GetBytes(), 0, sendPacket.Length);
            }
            catch (Exception e)
            {
                ConsoleUtils.Print(string.Format("Generate Token Failure: {0}:{1}", e.Source, e.Message));
                sendPacket = PacketParser.CreatePacket(ResponseEnum.Failure);
                packet.Stream.Write(sendPacket.GetBytes(), 0, sendPacket.Length);
                return;
            }
        }