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

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


            Asset asset = CreateAssetWrapper(type);
            asset.AssetData = data;
            asset.setAssetID(assetID);

            try { callback.execute(new AssetReceivedCallbackArgs(transfer, asset)); }
            catch (Exception e) { JLogger.error(e); }

            return;
        }
View Full Code Here


            Asset asset = CreateAssetWrapper(type);
            asset.AssetData = data;
            asset.setAssetID(assetID);

            try { callback.execute(new AssetReceivedCallbackArgs(transfer, asset)); }
            catch (Exception e) { JLogger.error(e); }

            return;
        }
View Full Code Here

                // No data could have been received before the TransferInfo packet
                download.AssetData = null;

                // Fire the event with our transfer that contains Success = false;
                try { download.Callback.execute(new AssetReceivedCallbackArgs(download, null)); }
                catch (Exception ex) { JLogger.error(ex); }
            }
            else
            {
                download.AssetData = new byte[download.Size];
View Full Code Here

                    {Transfers.remove(download.ID);}

                    // Fire the event with our transfer that contains Success = false
                    if (download.Callback != null)
                    {
                        try { download.Callback.execute(new AssetReceivedCallbackArgs(download, null)); }
                        catch (Exception ex) { JLogger.error(ex); }
                    }

                    return;
                }
            }

            // This assumes that every transfer packet except the last one is exactly 1000 bytes,
            // hopefully that is a safe assumption to make
            try
            {
              byte[] bytes = new byte[asset.TransferData.Data.length];
                Utils.arraycopy(asset.TransferData.Data, 0, bytes, 0, asset.TransferData.Data.length);
                download.pmap.put(asset.TransferData.Packet, bytes);
                download.Transferred += asset.TransferData.Data.length;
                JLogger.debug(String.format("AssetManager: TransferPacketHandler: got asset %s packet length %d of packet no %d", download.AssetID.toString(), asset.TransferData.Data.length, asset.TransferData.Packet));
            }
            catch (IllegalArgumentException ex)
            {
                JLogger.error(String.format("TransferPacket handling failed. TransferData.Data.Length=%d, AssetData.Length=%d, TransferData.Packet=%d",
                    asset.TransferData.Data.length, download.AssetData.length, asset.TransferData.Packet));
                return;
            }

            //Client.DebugLog(String.Format("Transfer packet {0}, received {1}/{2}/{3} bytes for asset {4}",
            //    asset.TransferData.Packet, asset.TransferData.Data.Length, transfer.Transferred, transfer.Size,
            //    transfer.AssetID.toString()));

            // Check if we downloaded the full asset
            if (download.Transferred >= download.Size)
            {
              int i =0;
             
              for(Entry<Integer, byte[]> entry:download.pmap.entrySet())
              {
                Utils.arraycopy(entry.getValue(), 0, download.AssetData, i, entry.getValue().length);
                i += entry.getValue().length;
              }
              download.pmap.clear();
                JLogger.debug("Transfer for asset " + download.AssetID.toString() + " completed");

                download.Success = true;
                synchronized(Transfers)
                {Transfers.remove(download.ID);}

                // Cache successful asset download
                Cache.saveAssetToCache(download.AssetID, download.AssetData);

                if (download.Callback != null)
                {
                    try { download.Callback.execute(new AssetReceivedCallbackArgs(download, WrapAsset(download))); }
                    catch (Exception ex) { JLogger.error(ex); }
                }
            }
        }
    }
View Full Code Here

TOP

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

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.