aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/AssetDownloadModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/AssetDownloadModule.cs204
1 files changed, 103 insertions, 101 deletions
diff --git a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs
index 07f13ce..d5f1b36 100644
--- a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs
@@ -175,117 +175,119 @@ namespace OpenSim.Region.Environment.Modules
175 } 175 }
176 } 176 }
177 177
178 private void RunAssetQueue() 178// TODO: unused
179 { 179// private void RunAssetQueue()
180 while (true) 180// {
181 { 181// while (true)
182 try 182// {
183 { 183// try
184 ProcessAssetQueue(); 184// {
185 Thread.Sleep(500); 185// ProcessAssetQueue();
186 } 186// Thread.Sleep(500);
187 catch (Exception) 187// }
188 { 188// catch (Exception)
189 // m_log.Error("[ASSET CACHE]: " + e.ToString()); 189// {
190 } 190// // m_log.Error("[ASSET CACHE]: " + e.ToString());
191 } 191// }
192 } 192// }
193// }
193 194
194 /// <summary> 195// TODO: unused
195 /// Process the asset queue which sends packets directly back to the client. 196// /// <summary>
196 /// </summary> 197// /// Process the asset queue which sends packets directly back to the client.
197 private void ProcessAssetQueue() 198// /// </summary>
198 { 199// private void ProcessAssetQueue()
199 //should move the asset downloading to a module, like has been done with texture downloading 200// {
200 if (AssetRequests.Count == 0) 201// //should move the asset downloading to a module, like has been done with texture downloading
201 { 202// if (AssetRequests.Count == 0)
202 //no requests waiting 203// {
203 return; 204// //no requests waiting
204 } 205// return;
205 // if less than 5, do all of them 206// }
206 int num = Math.Min(5, AssetRequests.Count); 207// // if less than 5, do all of them
208// int num = Math.Min(5, AssetRequests.Count);
207 209
208 AssetRequest req; 210// AssetRequest req;
209 for (int i = 0; i < num; i++) 211// for (int i = 0; i < num; i++)
210 { 212// {
211 req = (AssetRequest)AssetRequests[i]; 213// req = (AssetRequest)AssetRequests[i];
212 //Console.WriteLine("sending asset " + req.RequestAssetID); 214// //Console.WriteLine("sending asset " + req.RequestAssetID);
213 TransferInfoPacket Transfer = new TransferInfoPacket(); 215// TransferInfoPacket Transfer = new TransferInfoPacket();
214 Transfer.TransferInfo.ChannelType = 2; 216// Transfer.TransferInfo.ChannelType = 2;
215 Transfer.TransferInfo.Status = 0; 217// Transfer.TransferInfo.Status = 0;
216 Transfer.TransferInfo.TargetType = 0; 218// Transfer.TransferInfo.TargetType = 0;
217 if (req.AssetRequestSource == 2) 219// if (req.AssetRequestSource == 2)
218 { 220// {
219 Transfer.TransferInfo.Params = new byte[20]; 221// Transfer.TransferInfo.Params = new byte[20];
220 Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); 222// Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
221 int assType = (int)req.AssetInf.Type; 223// int assType = (int)req.AssetInf.Type;
222 Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); 224// Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
223 } 225// }
224 else if (req.AssetRequestSource == 3) 226// else if (req.AssetRequestSource == 3)
225 { 227// {
226 Transfer.TransferInfo.Params = req.Params; 228// Transfer.TransferInfo.Params = req.Params;
227 // Transfer.TransferInfo.Params = new byte[100]; 229// // Transfer.TransferInfo.Params = new byte[100];
228 //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); 230// //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
229 //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); 231// //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
230 } 232// }
231 Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; 233// Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length;
232 Transfer.TransferInfo.TransferID = req.TransferRequestID; 234// Transfer.TransferInfo.TransferID = req.TransferRequestID;
233 req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset); 235// req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset);
234 236
235 if (req.NumPackets == 1) 237// if (req.NumPackets == 1)
236 { 238// {
237 TransferPacketPacket TransferPacket = new TransferPacketPacket(); 239// TransferPacketPacket TransferPacket = new TransferPacketPacket();
238 TransferPacket.TransferData.Packet = 0; 240// TransferPacket.TransferData.Packet = 0;
239 TransferPacket.TransferData.ChannelType = 2; 241// TransferPacket.TransferData.ChannelType = 2;
240 TransferPacket.TransferData.TransferID = req.TransferRequestID; 242// TransferPacket.TransferData.TransferID = req.TransferRequestID;
241 TransferPacket.TransferData.Data = req.AssetInf.Data; 243// TransferPacket.TransferData.Data = req.AssetInf.Data;
242 TransferPacket.TransferData.Status = 1; 244// TransferPacket.TransferData.Status = 1;
243 req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); 245// req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
244 } 246// }
245 else 247// else
246 { 248// {
247 int processedLength = 0; 249// int processedLength = 0;
248 // libsecondlife hardcodes 1500 as the maximum data chunk size 250// // libsecondlife hardcodes 1500 as the maximum data chunk size
249 int maxChunkSize = 1250; 251// int maxChunkSize = 1250;
250 int packetNumber = 0; 252// int packetNumber = 0;
251 253
252 while (processedLength < req.AssetInf.Data.Length) 254// while (processedLength < req.AssetInf.Data.Length)
253 { 255// {
254 TransferPacketPacket TransferPacket = new TransferPacketPacket(); 256// TransferPacketPacket TransferPacket = new TransferPacketPacket();
255 TransferPacket.TransferData.Packet = packetNumber; 257// TransferPacket.TransferData.Packet = packetNumber;
256 TransferPacket.TransferData.ChannelType = 2; 258// TransferPacket.TransferData.ChannelType = 2;
257 TransferPacket.TransferData.TransferID = req.TransferRequestID; 259// TransferPacket.TransferData.TransferID = req.TransferRequestID;
258 260
259 int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); 261// int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
260 byte[] chunk = new byte[chunkSize]; 262// byte[] chunk = new byte[chunkSize];
261 Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); 263// Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length);
262 264
263 TransferPacket.TransferData.Data = chunk; 265// TransferPacket.TransferData.Data = chunk;
264 266
265 // 0 indicates more packets to come, 1 indicates last packet 267// // 0 indicates more packets to come, 1 indicates last packet
266 if (req.AssetInf.Data.Length - processedLength > maxChunkSize) 268// if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
267 { 269// {
268 TransferPacket.TransferData.Status = 0; 270// TransferPacket.TransferData.Status = 0;
269 } 271// }
270 else 272// else
271 { 273// {
272 TransferPacket.TransferData.Status = 1; 274// TransferPacket.TransferData.Status = 1;
273 } 275// }
274 276
275 req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset); 277// req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
276 278
277 processedLength += chunkSize; 279// processedLength += chunkSize;
278 packetNumber++; 280// packetNumber++;
279 } 281// }
280 } 282// }
281 } 283// }
282 284
283 //remove requests that have been completed 285// //remove requests that have been completed
284 for (int i = 0; i < num; i++) 286// for (int i = 0; i < num; i++)
285 { 287// {
286 AssetRequests.RemoveAt(0); 288// AssetRequests.RemoveAt(0);
287 } 289// }
288 } 290// }
289 291
290 /// <summary> 292 /// <summary>
291 /// Calculate the number of packets required to send the asset to the client. 293 /// Calculate the number of packets required to send the asset to the client.