public Packet FetchInventory(LLUUID OwnerID, LLUUID ItemID) { FetchInventoryPacket p = new FetchInventoryPacket(); p.InventoryData = new FetchInventoryPacket.InventoryDataBlock[1]; p.InventoryData[0] = new FetchInventoryPacket.InventoryDataBlock(); p.InventoryData[0].OwnerID = OwnerID; p.InventoryData[0].ItemID = ItemID; p.AgentData.AgentID = AgentID; p.AgentData.SessionID = SessionID; return p; }
public Packet FetchInventory(LLUUID OwnerID, LLUUID ItemID) { FetchInventoryPacket p = new FetchInventoryPacket(); p.InventoryData = new FetchInventoryPacket.InventoryDataBlock[1]; p.InventoryData[0] = new FetchInventoryPacket.InventoryDataBlock(); p.InventoryData[0].OwnerID = OwnerID; p.InventoryData[0].ItemID = ItemID; p.AgentData.AgentID = AgentID; p.AgentData.SessionID = SessionID; return(p); }
public void FetchInventory(SimClient userInfo, FetchInventoryPacket FetchItems) { if (this._agentsInventory.ContainsKey(userInfo.AgentID)) { AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID]; for (int i = 0; i < FetchItems.InventoryData.Length; i++) { if (agentInventory.InventoryItems.ContainsKey(FetchItems.InventoryData[i].ItemID)) { InventoryItem Item = agentInventory.InventoryItems[FetchItems.InventoryData[i].ItemID]; FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket(); InventoryReply.AgentData.AgentID = userInfo.AgentID; InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); InventoryReply.InventoryData[0].ItemID = Item.ItemID; InventoryReply.InventoryData[0].AssetID = Item.AssetID; InventoryReply.InventoryData[0].CreatorID = Item.CreatorID; InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0"); InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].Flags = 0; InventoryReply.InventoryData[0].FolderID = Item.FolderID; InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].InvType = Item.InvType; InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0"); InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].OwnerID = Item.OwnerID; InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].SalePrice = 100; InventoryReply.InventoryData[0].SaleType = 0; InventoryReply.InventoryData[0].Type = Item.Type; InventoryReply.InventoryData[0].CRC = libsecondlife.Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); userInfo.OutPacket(InventoryReply); } } } }
/// <summary> /// Request inventory items /// </summary> /// <param name="itemIDs">Inventory items to request</param> /// <param name="ownerIDs">Owners of the inventory items</param> public void RequestFetchInventory(List<LLUUID> itemIDs, List<LLUUID> ownerIDs) { if (itemIDs.Count != ownerIDs.Count) throw new ArgumentException("itemIDs and ownerIDs must contain the same number of entries"); FetchInventoryPacket fetch = new FetchInventoryPacket(); fetch.AgentData = new FetchInventoryPacket.AgentDataBlock(); fetch.AgentData.AgentID = _Client.Self.AgentID; fetch.AgentData.SessionID = _Client.Self.SessionID; fetch.InventoryData = new FetchInventoryPacket.InventoryDataBlock[itemIDs.Count]; for (int i = 0; i < itemIDs.Count; i++) { fetch.InventoryData[i] = new FetchInventoryPacket.InventoryDataBlock(); fetch.InventoryData[i].ItemID = itemIDs[i]; fetch.InventoryData[i].OwnerID = ownerIDs[i]; } _Client.Network.SendPacket(fetch); }
public void RequestFetchInventory(LLUUID itemID, LLUUID ownerID) { FetchInventoryPacket fetch = new FetchInventoryPacket(); fetch.AgentData = new FetchInventoryPacket.AgentDataBlock(); fetch.AgentData.AgentID = _Client.Self.AgentID; fetch.AgentData.SessionID = _Client.Self.SessionID; fetch.InventoryData = new FetchInventoryPacket.InventoryDataBlock[1]; fetch.InventoryData[0] = new FetchInventoryPacket.InventoryDataBlock(); fetch.InventoryData[0].ItemID = itemID; fetch.InventoryData[0].OwnerID = ownerID; _Client.Network.SendPacket(fetch); }
/// <summary> /// Request inventory items /// </summary> /// <param name="itemIDs">Inventory items to request</param> /// <param name="ownerID">Owners of the inventory items</param> /// <param name="callback"></param> /// <seealso cref="InventoryManager.OnItemReceived"/> public void RequestFetchItems(ICollection<UUID> itemIDs, UUID ownerID, FetchItemsCallback callback) { FetchRequest request = new FetchRequest(callback, itemIDs); lock (_FetchRequests) _FetchRequests.Add(request); // Send the packet: FetchInventoryPacket fetch = new FetchInventoryPacket(); fetch.AgentData = new FetchInventoryPacket.AgentDataBlock(); fetch.AgentData.AgentID = _Agents.AgentID; fetch.AgentData.SessionID = _Agents.SessionID; fetch.InventoryData = new FetchInventoryPacket.InventoryDataBlock[itemIDs.Count]; int i = 0; foreach (UUID item in itemIDs) { fetch.InventoryData[i] = new FetchInventoryPacket.InventoryDataBlock(); fetch.InventoryData[i].ItemID = item; fetch.InventoryData[i].OwnerID = ownerID; ++i; } _Network.SendPacket(fetch); }
/// <summary> /// Request inventory items /// </summary> /// <param name="itemIDs">Inventory items to request</param> /// <param name="ownerIDs">Owners of the inventory items</param> /// <seealso cref="InventoryManager.OnItemReceived"/> public void RequestFetchInventory(List<UUID> itemIDs, List<UUID> ownerIDs) { if (itemIDs.Count != ownerIDs.Count) throw new ArgumentException("itemIDs and ownerIDs must contain the same number of entries"); if (Client.Settings.HTTP_INVENTORY && Client.Network.CurrentSim.Caps != null && Client.Network.CurrentSim.Caps.CapabilityURI("FetchInventory2") != null) { RequestFetchInventoryCap(itemIDs, ownerIDs); return; } FetchInventoryPacket fetch = new FetchInventoryPacket(); fetch.AgentData = new FetchInventoryPacket.AgentDataBlock(); fetch.AgentData.AgentID = Client.Self.AgentID; fetch.AgentData.SessionID = Client.Self.SessionID; fetch.InventoryData = new FetchInventoryPacket.InventoryDataBlock[itemIDs.Count]; for (int i = 0; i < itemIDs.Count; i++) { fetch.InventoryData[i] = new FetchInventoryPacket.InventoryDataBlock(); fetch.InventoryData[i].ItemID = itemIDs[i]; fetch.InventoryData[i].OwnerID = ownerIDs[i]; } Client.Network.SendPacket(fetch); }
public bool GetInventoryItem(FetchInventoryPacket invPacket) { if (invPacket.AgentData.AgentID.Equals(libOwner)) // Tell grid surfer to forward request to region, because the Library is served from there (!) return false; if (connected) { string uri = InventoryServerURL + "/" + AuthToken + "/GetItem/"; for (int i = 0; i < invPacket.InventoryData.Length; i++) { InventoryItemBase item = new InventoryItemBase(); item.ID = invPacket.InventoryData[i].ItemID; item.Owner = invPacket.InventoryData[i].OwnerID; OpenSimComms.GetInventoryItem(uri, item, InventoryCallBack); } } // Tell grid surfer not to forward return true; }
protected virtual void ProcessInPacket(Packet Pack) { ack_pack(Pack); if (debug) { if (Pack.Type != PacketType.AgentUpdate) { Console.WriteLine(Pack.Type.ToString()); } } if (this.ProcessPacketMethod(Pack)) { //there is a handler registered that handled this packet type return; } else { System.Text.Encoding _enc = System.Text.Encoding.ASCII; switch (Pack.Type) { case PacketType.CompleteAgentMovement: if (this.m_child) { this.UpgradeClient(); } ClientAvatar.CompleteMovement(m_world); ClientAvatar.SendInitialPosition(); break; case PacketType.RegionHandshakeReply: m_world.SendLayerData(this); break; case PacketType.AgentWearablesRequest: ClientAvatar.SendInitialAppearance(); foreach (SimClient client in m_clientThreads.Values) { if (client.AgentID != this.AgentID) { ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket(); this.OutPacket(objupdate); client.ClientAvatar.SendAppearanceToOtherAgent(this); } } m_world.GetInitialPrims(this); break; case PacketType.AgentIsNowWearing: AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; //Console.WriteLine(Pack.ToString()); break; case PacketType.AgentSetAppearance: AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; // Console.WriteLine(appear.ToString()); this.ClientAvatar.SetAppearance(appear); break; case PacketType.ObjectAdd: m_world.AddNewPrim((ObjectAddPacket)Pack, this); break; case PacketType.ObjectLink: OpenSim.Framework.Console.MainConsole.Instance.WriteLine(Pack.ToString()); ObjectLinkPacket link = (ObjectLinkPacket)Pack; uint parentprimid = 0; OpenSim.world.Primitive parentprim = null; if (link.ObjectData.Length > 1) { parentprimid = link.ObjectData[0].ObjectLocalID; foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == parentprimid) { parentprim = (OpenSim.world.Primitive)ent; } } for (int i = 1; i < link.ObjectData.Length; i++) { foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == link.ObjectData[i].ObjectLocalID) { ((OpenSim.world.Primitive)ent).MakeParent(parentprim); } } } } break; case PacketType.ObjectScale: OpenSim.Framework.Console.MainConsole.Instance.WriteLine(Pack.ToString()); break; case PacketType.ObjectShape: ObjectShapePacket shape = (ObjectShapePacket)Pack; for (int i = 0; i < shape.ObjectData.Length; i++) { foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == shape.ObjectData[i].ObjectLocalID) { ((OpenSim.world.Primitive)ent).UpdateShape(shape.ObjectData[i]); } } } break; case PacketType.RequestImage: RequestImagePacket imageRequest = (RequestImagePacket)Pack; for (int i = 0; i < imageRequest.RequestImage.Length; i++) { m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image); } break; case PacketType.TransferRequest: //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); TransferRequestPacket transfer = (TransferRequestPacket)Pack; m_assetCache.AddAssetRequest(this, transfer); break; case PacketType.AgentUpdate: ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack); break; case PacketType.ObjectImage: ObjectImagePacket imagePack = (ObjectImagePacket)Pack; for (int i = 0; i < imagePack.ObjectData.Length; i++) { foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == imagePack.ObjectData[i].ObjectLocalID) { ((OpenSim.world.Primitive)ent).UpdateTexture(imagePack.ObjectData[i].TextureEntry); } } } break; case PacketType.ObjectFlagUpdate: ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == flags.AgentData.ObjectLocalID) { ((OpenSim.world.Primitive)ent).UpdateObjectFlags(flags); } } break; case PacketType.AssetUploadRequest: AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); break; case PacketType.RequestXfer: //Console.WriteLine(Pack.ToString()); break; case PacketType.SendXferPacket: this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack); break; case PacketType.CreateInventoryFolder: CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID); //Console.WriteLine(Pack.ToString()); break; case PacketType.CreateInventoryItem: //Console.WriteLine(Pack.ToString()); CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; if (createItem.InventoryBlock.TransactionID != LLUUID.Zero) { this.UploadAssets.CreateInventoryItem(createItem); } else { // Console.Write(Pack.ToString()); this.CreateInventoryItem(createItem); } break; case PacketType.FetchInventory: //Console.WriteLine("fetch item packet"); FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; m_inventoryCache.FetchInventory(this, FetchInventory); break; case PacketType.FetchInventoryDescendents: FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; m_inventoryCache.FetchInventoryDescendents(this, Fetch); break; case PacketType.UpdateInventoryItem: UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; //Console.WriteLine(Pack.ToString()); for (int i = 0; i < update.InventoryData.Length; i++) { if (update.InventoryData[i].TransactionID != LLUUID.Zero) { AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); if (asset != null) { // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache"); m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); } else { asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); if (asset != null) { //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache"); m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); } else { //Console.WriteLine("trying to update inventory item, but asset is null"); } } } else { m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]);; } } break; case PacketType.ViewerEffect: ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; foreach (SimClient client in m_clientThreads.Values) { if (client.AgentID != this.AgentID) { viewer.AgentData.AgentID = client.AgentID; viewer.AgentData.SessionID = client.SessionID; client.OutPacket(viewer); } } break; case PacketType.RequestTaskInventory: // Console.WriteLine(Pack.ToString()); RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket(); bool foundent = false; foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == requesttask.InventoryData.LocalID) { replytask.InventoryData.TaskID = ent.uuid; replytask.InventoryData.Serial = 0; replytask.InventoryData.Filename = new byte[0]; foundent = true; } } if (foundent) { this.OutPacket(replytask); } break; case PacketType.UpdateTaskInventory: // Console.WriteLine(Pack.ToString()); UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID); if (myinventory != null) { if (updatetask.UpdateData.Key == 0) { if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null) { if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7) { LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID; AssetBase assBase = this.m_assetCache.GetAsset(noteaid); if (assBase != null) { foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == updatetask.UpdateData.LocalID) { if (ent is OpenSim.world.Primitive) { this.m_world.AddScript(ent, Util.FieldToString(assBase.Data)); } } } } } } } } break; case PacketType.AgentAnimation: if (!m_child) { AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; for (int i = 0; i < AgentAni.AnimationList.Length; i++) { if (AgentAni.AnimationList[i].StartAnim) { ClientAvatar.current_anim = AgentAni.AnimationList[i].AnimID; ClientAvatar.anim_seq = 1; ClientAvatar.SendAnimPack(); } } } break; case PacketType.ObjectSelect: ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; for (int i = 0; i < incomingselect.ObjectData.Length; i++) { foreach (Entity ent in m_world.Entities.Values) { if (ent.localid == incomingselect.ObjectData[i].ObjectLocalID) { ((OpenSim.world.Primitive)ent).GetProperites(this); break; } } } break; } } }
public void FetchInventory(SimClient userInfo, FetchInventoryPacket FetchItems) { if (this._agentsInventory.ContainsKey(userInfo.AgentID)) { AgentInventory agentInventory = this._agentsInventory[userInfo.AgentID]; for (int i = 0; i < FetchItems.InventoryData.Length; i++) { if (agentInventory.InventoryItems.ContainsKey(FetchItems.InventoryData[i].ItemID)) { InventoryItem Item = agentInventory.InventoryItems[FetchItems.InventoryData[i].ItemID]; FetchInventoryReplyPacket InventoryReply = new FetchInventoryReplyPacket(); InventoryReply.AgentData.AgentID = userInfo.AgentID; InventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; InventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); InventoryReply.InventoryData[0].ItemID = Item.ItemID; InventoryReply.InventoryData[0].AssetID = Item.AssetID; InventoryReply.InventoryData[0].CreatorID = Item.CreatorID; InventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; InventoryReply.InventoryData[0].Description = _enc.GetBytes(Item.Description + "\0"); InventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].Flags = 0; InventoryReply.InventoryData[0].FolderID = Item.FolderID; InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); InventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].InvType = Item.InvType; InventoryReply.InventoryData[0].Name = _enc.GetBytes(Item.Name + "\0"); InventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].OwnerID = Item.OwnerID; InventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; InventoryReply.InventoryData[0].SalePrice = 100; InventoryReply.InventoryData[0].SaleType = 0; InventoryReply.InventoryData[0].Type = Item.Type; InventoryReply.InventoryData[0].CRC = libsecondlife.Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, InventoryReply.InventoryData[0].GroupID, 100, InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); userInfo.OutPacket(InventoryReply); } } } }
private Dictionary<UUID, InventoryBase> FetchInventoryItems(LLAgent agent, FetchInventoryPacket.InventoryDataBlock[] blocks) { Dictionary<UUID, InventoryBase> items = new Dictionary<UUID, InventoryBase>(blocks.Length); int operationCount = blocks.Length; bool sentRequest = false; for (int i = 0; i < blocks.Length; i++) { UUID itemID = blocks[i].ItemID; // TODO: Why does the client send fetch inventory packets with ItemID=UUID.Zero? if (itemID != UUID.Zero) { sentRequest = true; m_scheduler.FireAndForget( delegate(object o) { InventoryBase obj; if (m_inventoryClient.TryGetInventory(agent.ID, (UUID)o, out obj)) { lock (items) items[obj.ID] = obj; } --operationCount; }, itemID ); } else { m_log.Warn(agent.Name + "(" + agent.ID + ") tried to fetch inventory itemID UUID.Zero and ownerID " + blocks[i].OwnerID); } } if (sentRequest) { const int SLEEP_TIME = 100; int forceStop = (1000 * 5 * operationCount) / SLEEP_TIME; int n = 0; while (operationCount > 0 && n < forceStop) { Thread.Sleep(SLEEP_TIME); ++n; } if (n >= forceStop) m_log.Warn("FetchInventoryItems timed out, successfully fetched " + items.Count + " items"); } return items; }