Exemple #1
0
 public void Assets_OnReceived(AssetDownload transfer, Asset asset)
 {
     if (!IsExporting)
     {
         return;
     }
     if (transfer.Success)
     {
         AssetComplete(asset.AssetID);
         string sfile = SimAsset.CFileName(asset.AssetID, asset.AssetType);
         try
         {
             var data = asset.AssetData;
             if (data != null && data.Length > 1)
             {
                 lock (fileWriterLock)
                     File.WriteAllBytes(assetDumpDir + Path.GetFileName(sfile), asset.AssetData);
                 return;
             }
         }
         catch (Exception ex)
         {
             Logger.Log(ex.Message, Helpers.LogLevel.Error);
         }
     }
 }
Exemple #2
0
        private void Asset_Xfer(object sender, XferReceivedEventArgs e)
        {
            if (!IsExporting)
            {
                return;
            }
            UUID assetID   = GetAssetID(e.Xfer);
            var  assetType = e.Xfer.AssetType;

            if (assetType == AssetType.Unknown)
            {
                // probly an taskinv so ingnore
                return;
            }
            lock (ToDownloadAssets) if (e.Xfer.Success)
                {
                    AssetComplete(assetID);
                    string sfile = SimAsset.CFileName(assetID, assetType);
                    try
                    {
                        lock (fileWriterLock)
                            File.WriteAllBytes(assetDumpDir + Path.GetFileName(sfile), e.Xfer.AssetData);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(ex.Message, Helpers.LogLevel.Error);
                    }
                }
        }
        public void PurgeCache()
        {
            string sfile = Path.GetDirectoryName(SimAsset.CFileName(UUID.Zero, AssetType.Texture));

            if (Directory.Exists(sfile))
            {
                Directory.Delete(sfile, true);
                Directory.CreateDirectory(sfile);
            }
        }
Exemple #4
0
        /*
         *
         * private bool RequestObjectProperties(IList<SimObject> objects, int msPerRequest, Simulator sim)
         * {
         *  // Create an array of the local IDs of all the prims we are requesting properties for
         *  uint[] localids = new uint[objects.Count];
         *
         *  lock (PrimsWaiting)
         *  {
         *      PrimsWaiting.Clear();
         *
         *      for (int i = 0; i < objects.Count; ++i)
         *      {
         *          localids[i] = objects[i].LocalID;
         *          PrimsWaiting.Add(objects[i].ID, objects[i].Prim);
         *      }
         *  }
         *
         *  Client.Objects.SelectObjects(sim, localids);
         *
         *  return AllPropertiesReceived.WaitOne(2000 + msPerRequest * objects.Count, false);
         * }
         */
        private void Assets_OnImageReceived(TextureRequestState state, AssetTexture asset)
        {
            if (!IsExporting)
            {
                return;
            }
            lock (ToDownloadAssets) if (state == TextureRequestState.Finished)
                {
                    AssetComplete(asset.AssetID);

                    if (state == TextureRequestState.Finished)
                    {
                        string sfile = Path.GetFileName(SimAsset.CFileName(asset.AssetID, asset.AssetType));
                        try { lock (fileWriterLock) File.WriteAllBytes(assetDumpDir + sfile, asset.AssetData); }
                        catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client); }
                        return;

                        if (asset.Decode())
                        {
                            try { lock (fileWriterLock) File.WriteAllBytes(assetDumpDir + asset.AssetID + ".tga", asset.Image.ExportTGA()); }
                            catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client); }
                        }
                        else
                        {
                            try { lock (fileWriterLock) File.WriteAllBytes(assetDumpDir + sfile, asset.AssetData); }
                            catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client); }
                            return;
                        }

                        Logger.Log("Finished downloading image " + asset.AssetID, Helpers.LogLevel.Info, Client);
                    }
                    else
                    {
                        Logger.Log("Failed to download image " + asset.AssetID + ":" + state, Helpers.LogLevel.Warning, Client);
                    }
                }
        }