diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/TextureSender.cs | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/OpenSim/Region/Environment/Modules/TextureSender.cs b/OpenSim/Region/Environment/Modules/TextureSender.cs index 08da591..f2b3173 100644 --- a/OpenSim/Region/Environment/Modules/TextureSender.cs +++ b/OpenSim/Region/Environment/Modules/TextureSender.cs | |||
@@ -34,36 +34,59 @@ using OpenSim.Framework.Console; | |||
34 | 34 | ||
35 | namespace OpenSim.Region.Environment.Modules | 35 | namespace OpenSim.Region.Environment.Modules |
36 | { | 36 | { |
37 | /// <summary> | ||
38 | /// A TextureSender handles the process of receiving a texture requested by the client from the | ||
39 | /// AssetCache, and then sending that texture back to the client. | ||
40 | /// </summary> | ||
37 | public class TextureSender | 41 | public class TextureSender |
38 | { | 42 | { |
39 | private static readonly log4net.ILog m_log | 43 | private static readonly log4net.ILog m_log |
40 | = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 44 | = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
41 | 45 | ||
46 | /// <summary> | ||
47 | /// Records the number of times texture send has been called. | ||
48 | /// </summary> | ||
42 | public int counter = 0; | 49 | public int counter = 0; |
50 | |||
51 | /// <summary> | ||
52 | /// Holds the texture asset to send. | ||
53 | /// </summary> | ||
43 | private AssetBase m_asset; | 54 | private AssetBase m_asset; |
44 | public long DataPointer = 0; | 55 | |
45 | public int NumPackets = 0; | 56 | /// <summary> |
46 | public int PacketCounter = 0; | 57 | /// This is actually the number of extra packets required to send the texture data! We always assume |
58 | /// at least one is required. | ||
59 | /// </summary> | ||
60 | private int NumPackets = 0; | ||
61 | |||
62 | /// <summary> | ||
63 | /// Holds the packet number to send next. In this case, each packet is 1000 bytes long and starts | ||
64 | /// at the 600th byte (0th indexed). | ||
65 | /// </summary> | ||
66 | private int PacketCounter = 0; | ||
67 | |||
47 | public bool Cancel = false; | 68 | public bool Cancel = false; |
48 | public bool ImageLoaded = false; | 69 | public bool ImageLoaded = false; |
49 | |||
50 | public bool Sending = false; | 70 | public bool Sending = false; |
51 | 71 | ||
52 | public IClientAPI RequestUser; | 72 | private IClientAPI RequestUser; |
53 | public LLUUID RequestedAssetID; | ||
54 | public int RequestedDiscardLevel = -1; | ||
55 | public uint StartPacketNumber = 0; | ||
56 | 73 | ||
57 | // private int m_sentDiscardLevel = -1; | 74 | private int RequestedDiscardLevel = -1; |
75 | private uint StartPacketNumber = 0; | ||
58 | 76 | ||
59 | public TextureSender(IClientAPI client, LLUUID textureID, int discardLevel, uint packetNumber) | 77 | public TextureSender(IClientAPI client, int discardLevel, uint packetNumber) |
60 | { | 78 | { |
61 | RequestUser = client; | 79 | RequestUser = client; |
62 | RequestedAssetID = textureID; | ||
63 | RequestedDiscardLevel = discardLevel; | 80 | RequestedDiscardLevel = discardLevel; |
64 | StartPacketNumber = packetNumber; | 81 | StartPacketNumber = packetNumber; |
65 | } | 82 | } |
66 | 83 | ||
84 | /// <summary> | ||
85 | /// Load up the texture data to send. | ||
86 | /// </summary> | ||
87 | /// <param name="asset"> | ||
88 | /// A <see cref="AssetBase"/> | ||
89 | /// </param> | ||
67 | public void TextureReceived(AssetBase asset) | 90 | public void TextureReceived(AssetBase asset) |
68 | { | 91 | { |
69 | m_asset = asset; | 92 | m_asset = asset; |
@@ -79,6 +102,10 @@ namespace OpenSim.Region.Environment.Modules | |||
79 | PacketCounter = (int) StartPacketNumber; | 102 | PacketCounter = (int) StartPacketNumber; |
80 | } | 103 | } |
81 | 104 | ||
105 | /// <summary> | ||
106 | /// Send a texture packet to the client. | ||
107 | /// </summary> | ||
108 | /// <returns>True if the last packet has been sent, false otherwise.</returns> | ||
82 | public bool SendTexturePacket() | 109 | public bool SendTexturePacket() |
83 | { | 110 | { |
84 | SendPacket(); | 111 | SendPacket(); |
@@ -91,6 +118,9 @@ namespace OpenSim.Region.Environment.Modules | |||
91 | return false; | 118 | return false; |
92 | } | 119 | } |
93 | 120 | ||
121 | /// <summary> | ||
122 | /// Sends a texture packet to the client. | ||
123 | /// </summary> | ||
94 | private void SendPacket() | 124 | private void SendPacket() |
95 | { | 125 | { |
96 | if (PacketCounter <= NumPackets) | 126 | if (PacketCounter <= NumPackets) |
@@ -148,6 +178,12 @@ namespace OpenSim.Region.Environment.Modules | |||
148 | } | 178 | } |
149 | } | 179 | } |
150 | 180 | ||
181 | /// <summary> | ||
182 | /// Calculate the number of packets that will be required to send the texture loaded into this sender | ||
183 | /// This is actually the number of 1000 byte packets not including an initial 600 byte packet... | ||
184 | /// </summary> | ||
185 | /// <param name="length"></param> | ||
186 | /// <returns></returns> | ||
151 | private int CalculateNumPackets(int length) | 187 | private int CalculateNumPackets(int length) |
152 | { | 188 | { |
153 | int numPackets = 0; | 189 | int numPackets = 0; |