コード例 #1
0
        private void RequestXferHandler(Packet packet, LLAgent agent)
        {
            RequestXferPacket request = (RequestXferPacket)packet;

            string filename = Utils.BytesToString(request.XferID.Filename);

            UUID taskInventoryID;

            if (filename.StartsWith("inventory_") && filename.EndsWith(".tmp") && UUID.TryParse(filename.Substring(10, 36), out taskInventoryID))
            {
                // This is a request for a task inventory listing, which we generate on demand
                ISceneEntity entity;
                if (m_scene.TryGetEntity(taskInventoryID, out entity) && entity is LLPrimitive)
                {
                    LLPrimitive prim      = (LLPrimitive)entity;
                    byte[]      assetData = Encoding.UTF8.GetBytes(prim.Inventory.GetTaskInventoryAsset());

                    SendXferPacketPacket xfer = new SendXferPacketPacket();
                    xfer.XferID.ID = request.XferID.ID;

                    if (assetData.Length < 1000)
                    {
                        xfer.XferID.Packet   = 0 | LAST_PACKET_MARKER;
                        xfer.DataPacket.Data = new byte[assetData.Length + 4];
                        Utils.IntToBytes(assetData.Length, xfer.DataPacket.Data, 0);
                        Buffer.BlockCopy(assetData, 0, xfer.DataPacket.Data, 4, assetData.Length);

                        m_udp.SendPacket(agent, xfer, ThrottleCategory.Asset, false);
                        m_log.Debug("Completed single packet xfer download of " + filename);
                    }
                    else
                    {
                        xfer.XferID.Packet   = 0;
                        xfer.DataPacket.Data = new byte[1000 + 4];
                        Utils.IntToBytes(assetData.Length, xfer.DataPacket.Data, 0);
                        Buffer.BlockCopy(assetData, 0, xfer.DataPacket.Data, 4, 1000);

                        // We don't need the entire XferDownload class, just the asset data and the current packet number
                        XferDownload download = new XferDownload();
                        download.AssetData = assetData;
                        download.PacketNum = 1;
                        download.Filename  = filename;
                        lock (currentDownloads)
                            currentDownloads[request.XferID.ID] = download;

                        m_udp.SendPacket(agent, xfer, ThrottleCategory.Asset, false);
                    }
                }
                else
                {
                    m_log.Warn("Could not find primitive " + taskInventoryID);
                }
            }
            else
            {
                m_log.Warn("Got a RequestXfer for an unknown file: " + filename);
            }
        }
コード例 #2
0
 private UUID GetAssetID(XferDownload xferDownload)
 {
     //@todo
     throw new NotImplementedException();
 }