private void TransferPacketCallbackHandler(Packet packet, Simulator simulator) { #if DEBUG_PACKETS Console.WriteLine(packet); #endif TransferPacketPacket reply = (TransferPacketPacket)packet; LLUUID TransferID = reply.TransferData.TransferID; byte[] Data = reply.TransferData.Data; // Append data to data received. AssetRequestDownload request = htDownloadRequests[TransferID]; if (request == null) { return; } lock (request) { Array.Copy(Data, 0, request.AssetData, request.Received, Data.Length); request.Received += Data.Length; // If we've gotten all the data, mark it completed. if (request.Received >= request.Size) { Console.WriteLine("Download Complete"); request.Completed.Set(); } } }
// Download stuff private void TransferInfoCallbackHandler(Packet packet, Simulator simulator) { #if DEBUG_PACKETS slClient.Log(packet.ToString(), Helpers.LogLevel.Info); #endif TransferInfoPacket reply = (TransferInfoPacket)packet; LLUUID TransferID = reply.TransferInfo.TransferID; int Size = reply.TransferInfo.Size; int Status = reply.TransferInfo.Status; //TODO: AssetID should be pulled out of the TransferInfo, if available // Lookup the request for this packet if (!htDownloadRequests.ContainsKey(TransferID)) { //slClient.Log("Received unexpected TransferInfo packet." + Environment.NewLine + packet.ToString(), // Helpers.LogLevel.Warning); return; } AssetRequestDownload request = htDownloadRequests[TransferID]; // Mark it as either not found or update the request information if (Status == -2) { request.SetExpectedSize(Size); request.Fail("Asset Status -2 :: Likely Status Not Found"); } else { request.SetExpectedSize(Size); } }
/// <summary> /// Update the local Avatar Appearance information based on the contents of the assets as defined in the cached wearable data info. /// </summary> protected void GetAvatarAppearanceInfoFromWearableAssets() { // Make sure we have some Wearable Data to start with. if (AgentWearablesSignal.WaitOne(1000, false) == false) { Client.Log("Cannot get Visual Param data from wearable assets. AgentWearablesSignal not set.", Helpers.LogLevel.Error); return; } // Clear current look AgentTextureEntry = new LLObject.TextureEntry("C228D1CF4B5D4BA884F4899A0796AA97"); // if this isn't valid, blame JH ;-) AgentAppearanceParams = new SerializableDictionary <int, float>(); // Build params and texture entries from wearable data foreach (AgentWearablesUpdatePacket.WearableDataBlock wdb in AgentWearablesData) { if (wdb.ItemID == LLUUID.Zero) { continue; } AssetWearable wearableAsset; switch (wdb.WearableType) { case 0: case 1: case 2: case 3: wearableAsset = new AssetWearable_Body(wdb.AssetID, null); break; default: wearableAsset = new AssetWearable_Clothing(wdb.AssetID, null); break; } AssetRequestDownload request = Client.Assets.RequestInventoryAsset(wearableAsset.AssetID, wearableAsset.Type); if (request.Wait(AssetManager.DefaultTimeout) != AssetRequestDownload.RequestStatus.Success) { Client.Log("Asset (" + wearableAsset.AssetID.ToStringHyphenated() + ") unavailable (" + request.StatusMsg + ")", Helpers.LogLevel.Error); } else { wearableAsset.SetAssetData(request.GetAssetData()); } if ((wearableAsset.AssetData == null) || (wearableAsset.AssetData.Length == 0)) { Client.Log("Asset retrieval failed for AssetID: " + wearableAsset.AssetID, Helpers.LogLevel.Warning); } UpdateAgentTextureEntryAndAppearanceParams(wearableAsset); } UpdateAgentTextureEntryOrder(); }
public void GetInventoryAsset(Asset asset) { AssetRequestDownload request = RequestInventoryAsset(asset.AssetID, asset.Type); request.Wait(-1); asset.SetAssetData(request.GetAssetData()); }
private void TransferInfoCallbackHandler(Packet packet, Simulator simulator) { #if DEBUG_PACKETS slClient.DebugLog(packet); #endif TransferInfoPacket reply = (TransferInfoPacket)packet; LLUUID TransferID = reply.TransferInfo.TransferID; int Size = reply.TransferInfo.Size; int Status = reply.TransferInfo.Status; // Lookup the request for this packet AssetRequestDownload request = htDownloadRequests[TransferID]; if (request == null) { return; } // Mark it as either not found or update the request information if (Status == -2) { request.Status = false; request.StatusMsg = "Asset Status -2 :: Likely Status Not Found"; request.Size = 0; request.AssetData = new byte[0]; request.Completed.Set(); } else { request.Size = Size; request.AssetData = new byte[Size]; } }
/// <summary> /// Get the Asset data for an item, must be used when requesting a Notecard /// </summary> /// <remarks>It is the responsibility of the calling party to retrieve the asset data from the request object when it is compelte.</remarks> /// <param name="item"></param> public AssetRequestDownload RequestInventoryAsset(InventoryItem item) { if (!(item is InventoryWearable)) { if ((item.OwnerMask & (uint)AssetPermission.Copy) == 0) { throw new AssetPermissionException(item, slClient, "Asset data refused, Copy permission needed."); } if ((item.OwnerMask & (uint)AssetPermission.Modify) == 0 && (item.Type == 10)) { throw new AssetPermissionException(item, slClient, "Asset data refused, Modify permission needed for scripts."); } } LLUUID TransferID = LLUUID.Random(); AssetRequestDownload request = new AssetRequestDownload(slClient.Assets, TransferID, item.AssetID); request.UpdateLastPacketTime(); // last time we recevied a packet for this request htDownloadRequests[TransferID] = request; // prep packet based on asset type Packet packet; switch (item.Type) { case 5: //Shirt case 13: //Bodyshape packet = AssetPacketHelpers.TransferRequestDirect(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, item.AssetID, item.Type); break; default: packet = AssetPacketHelpers.TransferRequest(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, item); break; } // Send packet slClient.Network.SendPacket(packet); #if DEBUG_PACKETS slClient.Log(packet.ToString(), Helpers.LogLevel.Info); #endif return(request); }
/// <summary> /// Get Asset data, works with BodyShapes (type 13) but does not work with Notecards(type 7) /// </summary> public AssetRequestDownload RequestInventoryAsset(LLUUID AssetID, sbyte Type) { LLUUID TransferID = LLUUID.Random(); AssetRequestDownload request = new AssetRequestDownload(slClient.Assets, TransferID, AssetID); request.UpdateLastPacketTime(); // last time we recevied a packet for this request htDownloadRequests[TransferID] = request; Packet packet = AssetPacketHelpers.TransferRequestDirect(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, AssetID, Type); slClient.Network.SendPacket(packet); #if DEBUG_PACKETS slClient.Log(packet.ToString(), Helpers.LogLevel.Info); #endif return(request); }
/// <summary> /// Get the Asset data for an item, must be used when requesting a Notecard /// </summary> /// <param name="item"></param> public void GetInventoryAsset(InventoryItem item) { LLUUID TransferID = LLUUID.Random(); AssetRequestDownload request = new AssetRequestDownload(TransferID); request.Size = int.MaxValue; // Number of bytes expected request.Received = 0; // Number of bytes received request.UpdateLastPacketTime(); // last time we recevied a packet for this request htDownloadRequests[TransferID] = request; // prep packet based on asset type Packet packet; switch (item.Type) { case 5: //Shirt case 13: //Bodyshape packet = AssetPacketHelpers.TransferRequestDirect(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, item.AssetID, item.Type); break; default: packet = AssetPacketHelpers.TransferRequest(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, item); break; } // Send packet slClient.Network.SendPacket(packet); #if DEBUG_PACKETS slClient.DebugLog(packet); #endif request.Completed.WaitOne(); item.SetAssetData(request.AssetData); }
private void TransferPacketCallbackHandler(Packet packet, Simulator simulator) { #if DEBUG_PACKETS slClient.DebugLog(packet); #endif TransferPacketPacket reply = (TransferPacketPacket)packet; LLUUID TransferID = reply.TransferData.TransferID; byte[] Data = reply.TransferData.Data; // Append data to data received. AssetRequestDownload request = htDownloadRequests[TransferID]; if (request == null) { return; } // Add data to data dictionary. request.AssetDataReceived[reply.TransferData.Packet] = Data; request.Received += Data.Length; // If we've gotten all the data, mark it completed. if (request.Received >= request.Size) { int curPos = 0; foreach (KeyValuePair <int, byte[]> kvp in request.AssetDataReceived) { Array.Copy(kvp.Value, 0, request.AssetData, curPos, kvp.Value.Length); curPos += kvp.Value.Length; } request.Completed.Set(); } }
/// <summary> /// Get Asset data, works with BodyShapes (type 13) but does not work with Notecards(type 7) /// </summary> /// <param name="asset"></param> public void GetInventoryAsset(Asset asset) { LLUUID TransferID = LLUUID.Random(); AssetRequestDownload request = new AssetRequestDownload(TransferID); request.Size = int.MaxValue; // Number of bytes expected request.Received = 0; // Number of bytes received request.UpdateLastPacketTime(); // last time we recevied a packet for this request htDownloadRequests[TransferID] = request; Packet packet = AssetPacketHelpers.TransferRequestDirect(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, asset.AssetID, asset.Type); slClient.Network.SendPacket(packet); #if DEBUG_PACKETS slClient.DebugLog(packet); #endif request.Completed.WaitOne(); asset.SetAssetData(request.AssetData); }
/// <summary> /// Get the Asset data for an item /// </summary> /// <param name="item"></param> public void GetInventoryAsset(InventoryItem item) { LLUUID TransferID = LLUUID.GenerateUUID(); AssetRequestDownload request = new AssetRequestDownload(TransferID); request.Size = int.MaxValue; // Number of bytes expected request.Received = 0; // Number of bytes received request.UpdateLastPacketTime(); // last time we recevied a packet for this request htDownloadRequests[TransferID] = request; Packet packet = AssetPacketHelpers.TransferRequest(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, item); slClient.Network.SendPacket(packet); #if DEBUG_PACKETS Console.WriteLine(packet); #endif request.Completed.WaitOne(); item.SetAssetData(request.AssetData); }
private void TransferPacketCallbackHandler(Packet packet, Simulator simulator) { #if DEBUG_PACKETS slClient.Log(packet.ToString(), Helpers.LogLevel.Info); #endif TransferPacketPacket reply = (TransferPacketPacket)packet; LLUUID TransferID = reply.TransferData.TransferID; byte[] Data = reply.TransferData.Data; // Lookup the request for this packet if (!htDownloadRequests.ContainsKey(TransferID)) { //slClient.Log("Received unexpected TransferPacket packet." + Environment.NewLine + packet.ToString(), // Helpers.LogLevel.Warning); return; } AssetRequestDownload request = htDownloadRequests[TransferID]; // Append data to data received. request.AddDownloadedData(reply.TransferData.Packet, Data); }
/// <summary> /// Get the Asset data for an item, must be used when requesting a Notecard /// </summary> /// <param name="item"></param> public void GetInventoryAsset( InventoryItem item ) { LLUUID TransferID = LLUUID.Random(); AssetRequestDownload request = new AssetRequestDownload(TransferID); request.Size = int.MaxValue; // Number of bytes expected request.Received = 0; // Number of bytes received request.UpdateLastPacketTime(); // last time we recevied a packet for this request htDownloadRequests[TransferID] = request; // prep packet based on asset type Packet packet; switch (item.Type) { case 5: //Shirt case 13: //Bodyshape packet = AssetPacketHelpers.TransferRequestDirect(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, item.AssetID, item.Type); break; default: packet = AssetPacketHelpers.TransferRequest(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, item ); break; } // Send packet slClient.Network.SendPacket(packet); #if DEBUG_PACKETS slClient.DebugLog(packet); #endif request.Completed.WaitOne(); item.SetAssetData(request.AssetData); }
/// <summary> /// Get Asset data, works with BodyShapes (type 13) but does not work with Notecards(type 7) /// </summary> public AssetRequestDownload RequestInventoryAsset(LLUUID AssetID, sbyte Type) { LLUUID TransferID = LLUUID.Random(); AssetRequestDownload request = new AssetRequestDownload(slClient.Assets, TransferID, AssetID); request.UpdateLastPacketTime(); // last time we recevied a packet for this request htDownloadRequests[TransferID] = request; Packet packet = AssetPacketHelpers.TransferRequestDirect(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, AssetID, Type); slClient.Network.SendPacket(packet); #if DEBUG_PACKETS slClient.Log(packet.ToString(), Helpers.LogLevel.Info); #endif return request; }
/// <summary> /// Get the Asset data for an item, must be used when requesting a Notecard /// </summary> /// <remarks>It is the responsibility of the calling party to retrieve the asset data from the request object when it is compelte.</remarks> /// <param name="item"></param> public AssetRequestDownload RequestInventoryAsset(InventoryItem item) { if (!(item is InventoryWearable)) { if ((item.OwnerMask & (uint)AssetPermission.Copy) == 0) throw new AssetPermissionException(item, slClient, "Asset data refused, Copy permission needed."); if ((item.OwnerMask & (uint)AssetPermission.Modify) == 0 && (item.Type == 10)) throw new AssetPermissionException(item, slClient, "Asset data refused, Modify permission needed for scripts."); } LLUUID TransferID = LLUUID.Random(); AssetRequestDownload request = new AssetRequestDownload(slClient.Assets, TransferID, item.AssetID); request.UpdateLastPacketTime(); // last time we recevied a packet for this request htDownloadRequests[TransferID] = request; // prep packet based on asset type Packet packet; switch (item.Type) { case 5: //Shirt case 13: //Bodyshape packet = AssetPacketHelpers.TransferRequestDirect(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, item.AssetID, item.Type); break; default: packet = AssetPacketHelpers.TransferRequest(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, item ); break; } // Send packet slClient.Network.SendPacket(packet); #if DEBUG_PACKETS slClient.Log(packet.ToString(), Helpers.LogLevel.Info); #endif return request; }
/// <summary> /// Called each time a wearable asset is done downloading /// </summary> /// <param name="request"></param> void AManager_TransferRequestCompletedEvent(AssetRequest request) { if (!(request is AssetRequestDownload)) { return; } AssetRequestDownload dlrequest = (AssetRequestDownload)request; if (dlrequest.AssetID == null) { Client.Log("AssetID is null in AssetRequestDownload: " + dlrequest.StatusMsg, Helpers.LogLevel.Error); } WearableCacheQueueMutex.WaitOne(); // Remove from the download queue lock (WearableAssetQueue) { if (!WearableAssetQueue.Contains(dlrequest.AssetID)) { // Looks like we got an asset for something other then what we're waiting for, ignore it WearableCacheQueueMutex.ReleaseMutex(); return; } } // Since we got a response for this asset, remove it from the queue WearableAssetQueue.Remove(dlrequest.AssetID); LogWearableAssetQueueActivity("Received queued asset, and removed: " + dlrequest.AssetID); // If the request wasn't successful, then don't try to process it. if (request.Status != AssetRequest.RequestStatus.Success) { Client.Log("Error downloading wearable asset: " + dlrequest.AssetID, Helpers.LogLevel.Error); WearableCacheQueueMutex.ReleaseMutex(); return; } AssetWearable wearableAsset = WearableCache[dlrequest.AssetID]; wearableAsset.SetAssetData(dlrequest.GetAssetData()); if ((wearableAsset.AssetData == null) || (wearableAsset.AssetData.Length == 0)) { Client.Log("Asset retrieval failed for AssetID: " + wearableAsset.AssetID, Helpers.LogLevel.Error); WearableCacheQueueMutex.ReleaseMutex(); return; } else { UpdateAgentTextureEntryAndAppearanceParams(wearableAsset); UpdateAgentTextureEntryOrder(); lock (WearableAssetQueue) { if (WearableAssetQueue.Count > 0) { RequestNextQueuedWearableAsset(); WearableCacheQueueMutex.ReleaseMutex(); return; } } // Now that all the wearable assets are done downloading, // send an appearance packet SendAgentSetAppearance(); WearableCacheQueueMutex.ReleaseMutex(); return; } }
/// <summary> /// Get the Asset data for an item /// </summary> /// <param name="item"></param> public void GetInventoryAsset( InventoryItem item ) { LLUUID TransferID = LLUUID.GenerateUUID(); AssetRequestDownload request = new AssetRequestDownload(TransferID); request.Size = int.MaxValue; // Number of bytes expected request.Received = 0; // Number of bytes received request.UpdateLastPacketTime(); // last time we recevied a packet for this request htDownloadRequests[TransferID] = request; Packet packet = AssetPacketHelpers.TransferRequest(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, item ); slClient.Network.SendPacket(packet); #if DEBUG_PACKETS Console.WriteLine(packet); #endif request.Completed.WaitOne(); item.SetAssetData(request.AssetData); }