Tweaks to assetcache to make texture downloading better (I hope)

afrisby
Brian McBee 2007-08-27 04:20:14 +00:00
parent f6706e6cf8
commit 6e35ff2822
1 changed files with 14 additions and 13 deletions

View File

@ -534,7 +534,7 @@ namespace OpenSim.Framework.Communications.Caches
/// <param name="imageID"></param> /// <param name="imageID"></param>
public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber) public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber)
{ {
//Console.WriteLine("texture request for " + imageID.ToStringHyphenated()); //Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber);
//check to see if texture is in local cache, if not request from asset server //check to see if texture is in local cache, if not request from asset server
if (!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) if (!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId))
{ {
@ -570,8 +570,9 @@ namespace OpenSim.Framework.Communications.Caches
if (imag.Data.LongLength > 600) if (imag.Data.LongLength > 600)
{ {
//Console.WriteLine("{0}", imag.Data.LongLength);
//over 600 bytes so split up file //over 600 bytes so split up file
req.NumPackets = 1 + (int)(imag.Data.Length - 600) / 1000; req.NumPackets = 2 + (int)(imag.Data.Length - 601) / 1000;
//Console.WriteLine("texture is " + imag.Data.Length + " which we will send in " +req.NumPackets +" packets"); //Console.WriteLine("texture is " + imag.Data.Length + " which we will send in " +req.NumPackets +" packets");
} }
else else
@ -698,8 +699,7 @@ namespace OpenSim.Framework.Communications.Caches
{ {
SendPacket(); SendPacket();
counter++; counter++;
if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1))
if ((request.PacketCounter > request.NumPackets) | (counter > 100) | (request.NumPackets == 1))
{ {
return true; return true;
} }
@ -715,7 +715,7 @@ namespace OpenSim.Framework.Communications.Caches
//first time for this request so send imagedata packet //first time for this request so send imagedata packet
if (req.NumPackets == 1) if (req.NumPackets == 1)
{ {
//only one packet so send whole file //Console.WriteLine("only one packet so send whole file");
ImageDataPacket im = new ImageDataPacket(); ImageDataPacket im = new ImageDataPacket();
im.Header.Reliable = false; im.Header.Reliable = false;
im.ImageID.Packets = 1; im.ImageID.Packets = 1;
@ -727,7 +727,7 @@ namespace OpenSim.Framework.Communications.Caches
req.PacketCounter++; req.PacketCounter++;
//req.ImageInfo.l= time; //req.ImageInfo.l= time;
//System.Console.WriteLine("sent texture: " + req.ImageInfo.FullID); //System.Console.WriteLine("sent texture: " + req.ImageInfo.FullID);
// Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated()); //Console.WriteLine("sending single packet for " + req.ImageInfo.FullID.ToStringHyphenated());
} }
else else
{ {
@ -744,7 +744,7 @@ namespace OpenSim.Framework.Communications.Caches
req.PacketCounter++; req.PacketCounter++;
//req.ImageInfo.last_used = time; //req.ImageInfo.last_used = time;
//System.Console.WriteLine("sent first packet of texture: //System.Console.WriteLine("sent first packet of texture: " + req.ImageInfo.FullID);
//Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated()); //Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated());
} }
} }
@ -759,12 +759,13 @@ namespace OpenSim.Framework.Communications.Caches
im.ImageID.ID = req.ImageInfo.FullID; im.ImageID.ID = req.ImageInfo.FullID;
int size = req.ImageInfo.Data.Length - 600 - (1000 * (req.PacketCounter-1)); int size = req.ImageInfo.Data.Length - 600 - (1000 * (req.PacketCounter-1));
if (size > 1000) size = 1000; if (size > 1000) size = 1000;
//Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size);
im.ImageData.Data = new byte[size]; im.ImageData.Data = new byte[size];
Array.Copy(req.ImageInfo.Data, 600 + (1000 * (req.PacketCounter-1)), im.ImageData.Data, 0, size); Array.Copy(req.ImageInfo.Data, 600 + (1000 * (req.PacketCounter-1)), im.ImageData.Data, 0, size);
req.RequestUser.OutPacket(im); req.RequestUser.OutPacket(im);
req.PacketCounter++; req.PacketCounter++;
//req.ImageInfo.last_used = time; //req.ImageInfo.last_used = time;
//System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID); //System.Console.WriteLine("sent a packet of texture: "+req.ImageInfo.FullID);
} }
} }