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

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


            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;
                          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);

                          Client.assets.Cache.saveAssetToCache(textureID, responseData);
                      }
                      else // download failed
View Full Code Here


        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
View Full Code Here

        request.RequestImage[0].Image = textureID;
        request.RequestImage[0].Type = (byte)task.Type.getIndex();
        _Client.network.SendPacket(request);

        for (MethodDelegate<Void, TextureDownloadCallbackArgs> callback : task.Callbacks)
          callback.execute(new TextureDownloadCallbackArgs(TextureRequestState.Aborted, new AssetTexture(textureID, Utils.EmptyBytes)));

        _Client.assets.FireImageProgressEvent(task.RequestID, task.Transfer.Transferred, task.Transfer.Size);

        resetEvents[task.RequestSlot].set();

        RemoveTransfer(textureID);
      }
      else
      {
        RemoveTransfer(textureID);

        for (MethodDelegate<Void, TextureDownloadCallbackArgs> callback : task.Callbacks)
          callback.execute(new TextureDownloadCallbackArgs(TextureRequestState.Aborted, new AssetTexture(textureID, Utils.EmptyBytes)));

        _Client.assets.FireImageProgressEvent(task.RequestID, task.Transfer.Transferred, task.Transfer.Size);
      }
    }
  }
View Full Code Here

          task.Transfer.Transferred + " of " + task.Transfer.Size);

      AssetTexture texture = new AssetTexture(task.RequestID, task.Transfer.AssetData);
      for (MethodDelegate<Void, TextureDownloadCallbackArgs> callback: task.Callbacks)
      {
        callback.execute(new TextureDownloadCallbackArgs(TextureRequestState.Timeout, texture));
      }

      _Client.assets.FireImageProgressEvent(task.RequestID, task.Transfer.Transferred, task.Transfer.Size);

      RemoveTransfer(task.RequestID);
View Full Code Here

      if (task.State == TextureRequestState.Progress)
        resetEvents[task.RequestSlot].set();

      // fire callback to inform the caller
      for (MethodDelegate<Void, TextureDownloadCallbackArgs> callback: task.Callbacks)
        callback.execute(new TextureDownloadCallbackArgs(TextureRequestState.NotFound, new AssetTexture(imageNotFoundData.ImageID.ID, Utils.EmptyBytes)));

      resetEvents[task.RequestSlot].set();

      RemoveTransfer(imageNotFoundData.ImageID.ID);
    }
View Full Code Here

          RemoveTransfer(task.Transfer.ID);
          resetEvents[task.RequestSlot].set(); // free up request slot

          for (MethodDelegate<Void, TextureDownloadCallbackArgs> callback: task.Callbacks)
            callback.execute(new TextureDownloadCallbackArgs(TextureRequestState.Timeout, new AssetTexture(task.RequestID, task.Transfer.AssetData)));

          return;
        }
      }

      // The header is downloaded, we can insert this data in to the proper position
      // Only insert if we haven't seen this packet before
      synchronized (task.Transfer)
      {
        if (!task.Transfer.PacketsSeen.containsKey(image.ImageID.Packet))
        {
          task.Transfer.PacketsSeen.put(image.ImageID.Packet, image.ImageID.Packet);
          Utils.arraycopy(image.ImageData.Data, 0, task.Transfer.AssetData,
              task.Transfer.InitialDataSize + (1000 * (image.ImageID.Packet - 1)),
              image.ImageData.Data.length);
          task.Transfer.Transferred += image.ImageData.Data.length;
        }
      }

      task.Transfer.setTimeSinceLastPacket(0);

      if (task.Transfer.Transferred >= task.Transfer.Size)
      {
        //if DEBUG_TIMING
        long stopTime = Utils.getUnixTime();
        long requestDuration = stopTime - task.StartTime;

        long networkDuration = stopTime - task.NetworkTime;

        TotalTime += requestDuration;
        NetworkTime += networkDuration;
        TotalBytes += task.Transfer.Size;

        JLogger.debug(
            String.format(
                "Transfer Complete {0} [{1}] Total Request Time: {2}, Download Time {3}, Network {4}Kb/sec, Image Size {5} bytes",
                task.RequestID, task.RequestSlot, requestDuration, networkDuration,
                Math.round(task.Transfer.Size/networkDuration/(60*60)), task.Transfer.Size));
        //endif

        task.Transfer.Success = true;
        RemoveTransfer(task.Transfer.ID);
        resetEvents[task.RequestSlot].set(); // free up request slot
        _Client.assets.Cache.saveAssetToCache(task.RequestID, task.Transfer.AssetData);
        for (MethodDelegate<Void, TextureDownloadCallbackArgs> callback: task.Callbacks)
          callback.execute(new TextureDownloadCallbackArgs(TextureRequestState.Finished, new AssetTexture(task.RequestID, task.Transfer.AssetData)));

        _Client.assets.FireImageProgressEvent(task.RequestID, task.Transfer.Transferred, task.Transfer.Size);
      }
      else
      {
        if (task.ReportProgress)
        {
          for (MethodDelegate<Void, TextureDownloadCallbackArgs> callback: task.Callbacks)
            callback.execute(new TextureDownloadCallbackArgs(TextureRequestState.Progress,
                new AssetTexture(task.RequestID, task.Transfer.AssetData)));
        }
        _Client.assets.FireImageProgressEvent(task.RequestID, task.Transfer.Transferred,
            task.Transfer.Size);
      }
View Full Code Here

        resetEvents[task.RequestSlot].set();

        _Client.assets.Cache.saveAssetToCache(task.RequestID, task.Transfer.AssetData);

        for (MethodDelegate<Void, TextureDownloadCallbackArgs> callback : task.Callbacks)
          callback.execute(new TextureDownloadCallbackArgs(TextureRequestState.Finished, new AssetTexture(task.RequestID, task.Transfer.AssetData)));

        _Client.assets.FireImageProgressEvent(task.RequestID, task.Transfer.Transferred, task.Transfer.Size);
      }
      else
      {
        if (task.ReportProgress)
        {
          for (MethodDelegate<Void, TextureDownloadCallbackArgs> callback: task.Callbacks)
            callback.execute(new TextureDownloadCallbackArgs(TextureRequestState.Progress,
                new AssetTexture(task.RequestID, task.Transfer.AssetData)));
        }

        _Client.assets.FireImageProgressEvent(task.RequestID, task.Transfer.Transferred,
            task.Transfer.Size);
View Full Code Here

TOP

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

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.