/// <summary> /// Handles the Image Data packet, which includes the ID, and Size of the image, /// along with the first block of data for the image. If the image is small enough /// there will be no additional packets. /// </summary> /// <param name="packet"></param> /// <param name="simulator"></param> public void ImageDataCallbackHandler(Packet packet, Simulator simulator) { #if DEBUG_PACKETS slClient.DebugLog(packet); #endif ImageDataPacket reply = (ImageDataPacket)packet; LLUUID ImageID = reply.ImageID.ID; // unused? ushort Packets = reply.ImageID.Packets; uint Size = reply.ImageID.Size; byte[] Data = reply.ImageData.Data; // Lookup the request that this packet is for TransferRequest tr; lock (htDownloadRequests) { if (htDownloadRequests.ContainsKey(ImageID)) { tr = htDownloadRequests[ImageID]; } else { // Received a packet for an image we didn't request... return; } } // Initialize the request so that it's data buffer is the right size for the image tr.Size = Size; tr.AssetData = new byte[tr.Size]; tr.BaseDataReceived = Data.Length; // Copy the first block of image data into the request. Buffer.BlockCopy(Data, 0, tr.AssetData, (int)tr.Received, Data.Length); tr.Received += (uint)Data.Length; // Mark that the TransferRequest has received this header packet tr.ReceivedHeaderPacket.Set(); tr.TimeOfLastPacket = Helpers.GetUnixTime(); // last time we recevied a packet for this request // If we've gotten all the data, mark it completed. if (tr.Received >= tr.Size) { tr.Status = true; tr.Completed.Set(); // Fire off image downloaded event CacheImage(ImageID, tr.AssetData); FireImageRetrieved(ImageID, tr.AssetData, false); } }
internal void ItemCreate(InventoryItem iitem) { if (iiCreationInProgress != null) { throw new Exception("Can only create one item at a time, and an item creation is already in progress."); } try { ItemCreationCompleted = new ManualResetEvent(false); iiCreationInProgress = iitem; Packet packet = InvPacketHelper.CreateInventoryItem(iitem); int i = 0; do { if (i++ > 10) { throw new Exception("Could not create " + iitem.Name); } slClient.Network.SendPacket(packet); #if DEBUG_PACKETS slClient.DebugLog(packet); #endif } while (!ItemCreationCompleted.WaitOne(5000, false)); } finally { iiCreationInProgress = null; } }
/// <summary> /// Adds an image to this baking texture and potentially processes it, or /// stores it for processing later /// </summary> /// <param name="index">The baking texture index of the image to be added</param> /// <param name="jp2data">JPEG2000 compressed image to be added to the /// baking texture</param> /// <returns>True if this texture is completely baked and JPEG2000 data /// is available, otherwise false</returns> public bool AddTexture(AppearanceManager.TextureIndex index, AssetTexture texture) { lock (Textures) { texture.Decode(); Textures.Add(index, texture); Client.DebugLog("Adding texture " + index.ToString() + " to bake " + BakeType.ToString()); } if (Textures.Count == TextureCount) { Bake(); return(true); } else { return(false); } }
protected void SendFirstPacket() { Packet packet; if (AssetBeingTransferd._AssetData.Length > 1000) { packet = AssetPacketHelpers.AssetUploadRequestHeaderOnly(AssetBeingTransferd, _TransactionID); } else { packet = AssetPacketHelpers.AssetUploadRequest(AssetBeingTransferd, _TransactionID); } _Client.Network.SendPacket(packet); #if DEBUG_PACKETS slClient.DebugLog(packet); #endif #if DEBUG_HEADERS _Client.DebugLog(packet.Header.ToString()); #endif }
internal void SendFirstPacket() { Packet packet; if (this.MyAsset._AssetData.Length > 1000) { packet = AssetPacketHelpers.AssetUploadRequestHeaderOnly(this.MyAsset, this.TransactionID); } else { packet = AssetPacketHelpers.AssetUploadRequest(this.MyAsset, this.TransactionID); } slClient.Network.SendPacket(packet); #if DEBUG_PACKETS slClient.DebugLog(packet); #endif #if DEBUG_HEADERS slClient.DebugLog(packet.Header.ToString()); #endif }
private void RequiredVoiceVersionEventHandler(string message, LLSD llsd, Simulator simulator) { LLSDMap body = (LLSDMap)llsd; if (body.ContainsKey("major_version")) { int majorVersion = body["major_version"].AsInteger(); if (VOICE_MAJOR_VERSION != majorVersion) { Client.Log(String.Format("Voice version mismatch! Got {0}, expecting {1}. Disabling the voice manager", majorVersion, VOICE_MAJOR_VERSION), Helpers.LogLevel.Error); Enabled = false; } else { Client.DebugLog("Voice version " + majorVersion + " verified"); } } }
/// <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 cmdUpload_Click(object sender, EventArgs e) { SendToID = LLUUID.Zero; string sendTo = txtSendtoName.Text.Trim(); if (sendTo.Length > 0) { AutoResetEvent lookupEvent = new AutoResetEvent(false); LLUUID thisQueryID = LLUUID.Random(); bool lookupSuccess = false; DirectoryManager.DirPeopleReplyCallback callback = delegate(LLUUID queryID, List <DirectoryManager.AgentSearchData> matchedPeople) { if (queryID == thisQueryID) { if (matchedPeople.Count > 0) { SendToID = matchedPeople[0].AgentID; lookupSuccess = true; } lookupEvent.Set(); } }; Client.Directory.OnDirPeopleReply += callback; Client.Directory.StartPeopleSearch(DirectoryManager.DirFindFlags.People, sendTo, 0, thisQueryID); bool eventSuccess = lookupEvent.WaitOne(10 * 1000, false); Client.Directory.OnDirPeopleReply -= callback; if (eventSuccess && lookupSuccess) { Client.Log("Will send uploaded image to avatar " + SendToID.ToString(), Helpers.LogLevel.Info); } else { MessageBox.Show("Could not find avatar \"" + sendTo + "\", upload cancelled"); return; } } if (UploadData != null) { prgUpload.Value = 0; cmdLoad.Enabled = false; cmdUpload.Enabled = false; grpLogin.Enabled = false; string name = System.IO.Path.GetFileNameWithoutExtension(FileName); Client.Inventory.RequestCreateItemFromAsset(UploadData, name, "Uploaded with SL Image Upload", AssetType.Texture, InventoryType.Texture, Client.Inventory.FindFolderForType(AssetType.Texture), delegate(bool success, string status, LLUUID itemID, LLUUID assetID) { if (this.InvokeRequired) { BeginInvoke(new MethodInvoker(EnableControls)); } else { EnableControls(); } if (success) { AssetID = assetID; UpdateAssetID(); // Fix the permissions on the new upload since they are fscked by default InventoryItem item = Client.Inventory.FetchItem(itemID, Client.Self.AgentID, 1000 * 15); if (item != null) { item.Permissions.EveryoneMask = PermissionMask.All; item.Permissions.NextOwnerMask = PermissionMask.All; Client.Inventory.RequestUpdateItem(item); Client.Log("Created inventory item " + itemID.ToString(), Helpers.LogLevel.Info); MessageBox.Show("Created inventory item " + itemID.ToString()); // FIXME: We should be watching the callback for RequestUpdateItem instead of a dumb sleep System.Threading.Thread.Sleep(2000); if (SendToID != LLUUID.Zero) { Client.Log("Sending item to " + SendToID.ToString(), Helpers.LogLevel.Info); Client.Inventory.GiveItem(itemID, name, AssetType.Texture, SendToID, true); MessageBox.Show("Sent item to " + SendToID.ToString()); } } else { Client.DebugLog("Created inventory item " + itemID.ToString() + " but failed to fetch it," + " cannot update permissions or send to another avatar"); MessageBox.Show("Created inventory item " + itemID.ToString() + " but failed to fetch it," + " cannot update permissions or send to another avatar"); } } else { MessageBox.Show("Asset upload failed: " + status); } } ); } }