Package com.ngt.jopenmetaverse.shared.sim.events.asm

Examples of com.ngt.jopenmetaverse.shared.sim.events.asm.ImageDownload


      return null;

    byte[] imageData = getCachedAssetBytes(imageID);
    if (imageData == null)
      return null;
    ImageDownload transfer = new ImageDownload();
    transfer.AssetType = AssetType.Texture;
    transfer.ID = imageID;
    transfer.Simulator = Client.network.getCurrentSim();
    transfer.Size = imageData.length;
    transfer.Success = true;
View Full Code Here


        byte[] assetData;
        // Do we have this image in the cache?
        if (Client.assets.Cache.hasAsset(textureID)
            && (assetData = Client.assets.Cache.getCachedAssetBytes(textureID)) != null)
        {
            ImageDownload image = new ImageDownload();
            image.ID = textureID;
            image.AssetData = assetData;
            image.Size = image.AssetData.length;
            image.Transferred = image.AssetData.length;
            image.ImageType = imageType;
            image.AssetType = AssetType.Texture;
            image.Success = true;

            callback.execute(new TextureDownloadCallbackArgs(TextureRequestState.Finished, new AssetTexture(image.ID, image.AssetData)));
           
            FireImageProgressEvent(image.ID, (int)image.Transferred, image.Size);
            return;
        }

        MethodDelegate<Void, HttpBaseDownloadProgressArg> progressHandler = null;
        if (progress)
        {
          progressHandler =  new MethodDelegate<Void, HttpBaseDownloadProgressArg>(){
        public Void execute(HttpBaseDownloadProgressArg e) {
//          HttpRequestBase request = e.getRequest();
//          HttpResponse response = e.getResponse();
          int bytesReceived = e.getBytesReceived();
          int totalBytesToReceive  = e.getTotalBytesToReceive();
                    FireImageProgressEvent(textureID, bytesReceived, totalBytesToReceive);
          return null;
        }
          };
        }
       
        MethodDelegate<Void,HttpBaseRequestCompletedArg> downloadCompletedHanlder = new MethodDelegate<Void,HttpBaseRequestCompletedArg>()
            {
          public Void execute(HttpBaseRequestCompletedArg e) {
//            HttpRequestBase request = e.getRequest();
//            HttpResponse response = e.getResponse();
            byte[] responseData = e.getResponseData();
            Exception error = e.getError();
             if (error == null && responseData != null) // success
                      {
                          ImageDownload image = new ImageDownload();
                          image.ID = textureID;
                          image.AssetData = responseData;
                          image.Size = image.AssetData.length;
                          image.Transferred = image.AssetData.length;
                          image.ImageType = imageType;
View Full Code Here

    {
      for (TaskInfo transfer : _Transfers.values())
      {
        if (transfer.State == TextureRequestState.Progress)
        {
          ImageDownload download = transfer.Transfer;

          // Find the first missing packet in the download
          int packet = 0;
          synchronized (download)
          {
            if (download.PacketsSeen != null && download.PacketsSeen.size() > 0)
              packet = GetFirstMissingPacket(download.PacketsSeen);

            if (download.getTimeSinceLastPacket() > 5000)
            {
              // We're not receiving data for this texture fast enough, bump up the priority by 5%
              download.Priority *= 1.05f;

              download.setTimeSinceLastPacket(0);
              RequestImage(download.ID, download.ImageType, download.Priority, download.DiscardLevel, packet);
            }
            if (download.getTimeSinceLastPacket() > Settings.PIPELINE_REQUEST_TIMEOUT)
            {
              resetEvents[transfer.RequestSlot].set();
            }
          }
        }
View Full Code Here

    if (callback != null)
    {
      if (_Client.assets.Cache.hasAsset(textureID))
      {
        ImageDownload image = new ImageDownload();
        image.ID = textureID;
        image.AssetData = _Client.assets.Cache.getCachedAssetBytes(textureID);
        image.Size = image.AssetData.length;
        image.Transferred = image.AssetData.length;
        image.ImageType = imageType;
        image.AssetType = AssetType.Texture;
        image.Success = true;

        callback.execute(new TextureDownloadCallbackArgs(TextureRequestState.Finished,
            new AssetTexture(image.ID, image.AssetData)));

        _Client.assets.FireImageProgressEvent(image.ID, image.Transferred, image.Size);
      }
      else
      {
        synchronized (_Transfers)
        {
          TaskInfo request;

          if ((request = _Transfers.get(textureID))!=null)
          {
            request.Callbacks.add(callback);
          }
          else
          {
            request = new TaskInfo();
            request.State = TextureRequestState.Pending;
            request.RequestID = textureID;
            request.ReportProgress = progressive;
            request.RequestSlot = -1;
            request.Type = imageType;

            request.Callbacks = new ArrayList<MethodDelegate<Void, TextureDownloadCallbackArgs>>();
            request.Callbacks.add(callback);

            ImageDownload downloadParams = new ImageDownload();
            downloadParams.ID = textureID;
            downloadParams.Priority = priority;
            downloadParams.ImageType = imageType;
            downloadParams.DiscardLevel = discardLevel;
View Full Code Here

            JLogger.debug(String.format("Updating priority on image transfer %s to %f, %f% complete",
                imageID, task.Transfer.Priority, Math.round(percentComplete)));
        }
        else
        {
          ImageDownload transfer = task.Transfer;
          transfer.Simulator = _Client.network.getCurrentSim();
        }

        // Build and send the request packet
        RequestImagePacket request = new RequestImagePacket();
View Full Code Here

TOP

Related Classes of com.ngt.jopenmetaverse.shared.sim.events.asm.ImageDownload

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.