Manage asset transactions for a single agent.
        /// <summary>
        ///     Request that a client (agent) begin an asset transfer.
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="assetID"></param>
        /// <param name="transaction"></param>
        /// <param name="type"></param>
        /// <param name="data"></param>
        /// <param name="storeLocal"></param>
        /// <param name="tempFile"></param>
        public void HandleUDPUploadRequest(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type,
                                           byte[] data, bool storeLocal, bool tempFile)
        {
//            MainConsole.Instance.Debug("HandleUDPUploadRequest - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile);

            if (((AssetType)type == AssetType.Texture ||
                 (AssetType)type == AssetType.Sound ||
                 (AssetType)type == AssetType.TextureTGA ||
                 (AssetType)type == AssetType.Animation) &&
                tempFile == false)
            {
                IScene       scene = remoteClient.Scene;
                IMoneyModule mm    = scene.RequestModuleInterface <IMoneyModule>();

                if (mm != null)
                {
                    if (!mm.Charge(remoteClient.AgentId, mm.UploadCharge, "", TransactionType.UploadCharge))
                    {
                        remoteClient.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
                        return;
                    }
                }
            }

            AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);

            AssetXferUploader uploader = transactions.RequestXferUploader(transaction);

            if (uploader != null)
            {
                uploader.StartUpload(remoteClient, assetID, transaction, type, data, storeLocal, tempFile);
            }
        }
예제 #2
0
        /// <summary>
        ///     AssetXferUploader constructor
        /// </summary>
        /// <param name='transactions'></param>
        /// <param name='scene'></param>
        /// <param name='transactionID'></param>
        /// <param name='dumpAssetToFile'>
        ///     If true then when the asset is uploaded it is dumped to a file with the format
        ///     String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat",
        ///     now.Year, now.Month, now.Day, now.Hour, now.Minute,
        ///     now.Second, m_asset.Name, m_asset.Type);
        ///     for debugging purposes.
        /// </param>
        public AssetXferUploader(
            AgentAssetTransactions transactions, IScene scene, UUID transactionID, bool dumpAssetToFile)
        {
            m_asset = new AssetBase();

            m_transactions    = transactions;
            m_transactionID   = transactionID;
            m_Scene           = scene;
            m_dumpAssetToFile = dumpAssetToFile;
        }
        /// <summary>
        ///     Get the collection of asset transactions for the given user.  If one does not already exist, it
        ///     is created.
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        private AgentAssetTransactions GetUserTransactions(UUID userID)
        {
            lock (AgentTransactions)
            {
                if (!AgentTransactions.ContainsKey(userID))
                {
                    AgentAssetTransactions transactions = new AgentAssetTransactions(userID, m_scene, false);
                    AgentTransactions.Add(userID, transactions);
                }

                return(AgentTransactions[userID]);
            }
        }
        /// <summary>
        ///     Handle asset transfer data packets received in response to the asset upload request in
        ///     HandleUDPUploadRequest()
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="xferID"></param>
        /// <param name="packetID"></param>
        /// <param name="data"></param>
        public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
        {
            //MainConsole.Instance.Debug("xferID: " + xferID + "  packetID: " + packetID + "  data!");
            AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);

            IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>();

            if (monitorModule != null)
            {
                INetworkMonitor networkMonitor = monitorModule.GetMonitor <INetworkMonitor>(m_scene);
                networkMonitor.AddPendingUploads(1);
            }

            transactions.HandleXfer(remoteClient, xferID, packetID, data);
        }
        /// <summary>
        ///     Update a task inventory item with data that has been received through a transaction.
        ///     This is currently called when, for instance, a notecard in a prim is saved.  The data is sent
        ///     up through a single AssetUploadRequest.  A subsequent UpdateTaskInventory then references the transaction
        ///     and comes through this method.
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="part"></param>
        /// <param name="transactionID"></param>
        /// <param name="item"></param>
        public void HandleTaskItemUpdateFromTransaction(
            IClientAPI remoteClient, ISceneChildEntity part, UUID transactionID, TaskInventoryItem item)
        {
            //MainConsole.Instance.DebugFormat(
            //    "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}", item.Name);

            AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);

            IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>();

            if (monitorModule != null)
            {
                INetworkMonitor networkMonitor = monitorModule.GetMonitor <INetworkMonitor>(m_scene);
                networkMonitor.AddPendingUploads(1);
            }

            transactions.RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item);
        }
        /// <summary>
        ///     Create an inventory item from data that has been received through a transaction.
        ///     This is called when new clothing or body parts are created.  It may also be called in other
        ///     situations.
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="transactionID"></param>
        /// <param name="folderID"></param>
        /// <param name="callbackID"></param>
        /// <param name="description"></param>
        /// <param name="name"></param>
        /// <param name="invType"></param>
        /// <param name="type"></param>
        /// <param name="wearableType"></param>
        /// <param name="nextOwnerMask"></param>
        public void HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID,
                                                      uint callbackID, string description, string name, sbyte invType,
                                                      sbyte type, byte wearableType, uint nextOwnerMask)
        {
            //MainConsole.Instance.DebugFormat(
            //    "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name);

            AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);

            IMonitorModule monitorModule = m_scene.RequestModuleInterface <IMonitorModule>();

            if (monitorModule != null)
            {
                INetworkMonitor networkMonitor = monitorModule.GetMonitor <INetworkMonitor>(m_scene);
                networkMonitor.AddPendingUploads(1);
            }

            transactions.RequestCreateInventoryItem(
                remoteClient, transactionID, folderID, callbackID, description,
                name, invType, type, wearableType, nextOwnerMask);
        }
예제 #7
0
        /// <summary>
        ///     AssetXferUploader constructor
        /// </summary>
        /// <param name='transactions'></param>
        /// <param name='scene'></param>
        /// <param name='transactionID'></param>
        /// <param name='dumpAssetToFile'>
        ///     If true then when the asset is uploaded it is dumped to a file with the format
        ///     String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat",
        ///     now.Year, now.Month, now.Day, now.Hour, now.Minute,
        ///     now.Second, m_asset.Name, m_asset.Type);
        ///     for debugging purposes.
        /// </param>
        public AssetXferUploader(
            AgentAssetTransactions transactions, IScene scene, UUID transactionID, bool dumpAssetToFile)
        {
            m_asset = new AssetBase();

            m_transactions = transactions;
            m_transactionID = transactionID;
            m_Scene = scene;
            m_dumpAssetToFile = dumpAssetToFile;
        }
        /// <summary>
        ///     Get the collection of asset transactions for the given user.  If one does not already exist, it
        ///     is created.
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        AgentAssetTransactions GetUserTransactions(UUID userID)
        {
            lock (AgentTransactions)
            {
                if (!AgentTransactions.ContainsKey(userID))
                {
                    AgentAssetTransactions transactions = new AgentAssetTransactions(userID, m_scene, false);
                    AgentTransactions.Add(userID, transactions);
                }

                return AgentTransactions[userID];
            }
        }