aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
authorTeravus Ovares2008-06-18 23:04:15 +0000
committerTeravus Ovares2008-06-18 23:04:15 +0000
commitcb29926e3cefedd9bea3c26b1b7f079c8209f6fa (patch)
treebbf08176c4257299b825d899960f750266b4df1a /OpenSim/Framework/Communications
parentcommit justin's grafitti board to the base OpenSim script (diff)
downloadopensim-SC_OLD-cb29926e3cefedd9bea3c26b1b7f079c8209f6fa.zip
opensim-SC_OLD-cb29926e3cefedd9bea3c26b1b7f079c8209f6fa.tar.gz
opensim-SC_OLD-cb29926e3cefedd9bea3c26b1b7f079c8209f6fa.tar.bz2
opensim-SC_OLD-cb29926e3cefedd9bea3c26b1b7f079c8209f6fa.tar.xz
* Refactors call to OutPacket out of AssetCache and into LLClientView
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs85
1 files changed, 17 insertions, 68 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index a1d9c73..2c51160 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -612,80 +612,29 @@ namespace OpenSim.Framework.Communications.Cache
612 int num = Math.Min(5, AssetRequests.Count); 612 int num = Math.Min(5, AssetRequests.Count);
613 613
614 AssetRequest req; 614 AssetRequest req;
615 AssetRequestToClient req2 = null;
615 for (int i = 0; i < num; i++) 616 for (int i = 0; i < num; i++)
616 { 617 {
617 req = (AssetRequest)AssetRequests[i]; 618 req = (AssetRequest)AssetRequests[i];
618 //Console.WriteLine("sending asset " + req.RequestAssetID); 619 if (req2 == null)
619 TransferInfoPacket Transfer = new TransferInfoPacket();
620 Transfer.TransferInfo.ChannelType = 2;
621 Transfer.TransferInfo.Status = 0;
622 Transfer.TransferInfo.TargetType = 0;
623 if (req.AssetRequestSource == 2)
624 { 620 {
625 Transfer.TransferInfo.Params = new byte[20]; 621 req2 = new AssetRequestToClient();
626 Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
627 int assType = (int)req.AssetInf.Type;
628 Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
629 } 622 }
630 else if (req.AssetRequestSource == 3) 623 // Trying to limit memory usage by only creating AssetRequestToClient if needed
631 { 624 //req2 = new AssetRequestToClient();
632 Transfer.TransferInfo.Params = req.Params; 625 req2.AssetInf = (AssetBase)req.AssetInf;
633 // Transfer.TransferInfo.Params = new byte[100]; 626 req2.AssetRequestSource = req.AssetRequestSource;
634 //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); 627 req2.DataPointer = req.DataPointer;
635 //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); 628 req2.DiscardLevel = req.DiscardLevel;
636 } 629 req2.ImageInfo = (AssetBase)req.ImageInfo;
637 Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; 630 req2.IsTextureRequest = req.IsTextureRequest;
638 Transfer.TransferInfo.TransferID = req.TransferRequestID; 631 req2.NumPackets = req.NumPackets;
639 Transfer.Header.Zerocoded = true; 632 req2.PacketCounter = req.PacketCounter;
640 req.RequestUser.OutPacket(Transfer, ThrottleOutPacketType.Asset); 633 req2.Params = req.Params;
634 req2.RequestAssetID = req.RequestAssetID;
635 req2.TransferRequestID = req.TransferRequestID;
636 req.RequestUser.SendAsset(req2);
641 637
642 if (req.NumPackets == 1)
643 {
644 TransferPacketPacket TransferPacket = new TransferPacketPacket();
645 TransferPacket.TransferData.Packet = 0;
646 TransferPacket.TransferData.ChannelType = 2;
647 TransferPacket.TransferData.TransferID = req.TransferRequestID;
648 TransferPacket.TransferData.Data = req.AssetInf.Data;
649 TransferPacket.TransferData.Status = 1;
650 TransferPacket.Header.Zerocoded = true;
651 req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
652 }
653 else
654 {
655 int processedLength = 0;
656 // libsecondlife hardcodes 1500 as the maximum data chunk size
657 int maxChunkSize = 1250;
658 int packetNumber = 0;
659
660 while (processedLength < req.AssetInf.Data.Length)
661 {
662 TransferPacketPacket TransferPacket = new TransferPacketPacket();
663 TransferPacket.TransferData.Packet = packetNumber;
664 TransferPacket.TransferData.ChannelType = 2;
665 TransferPacket.TransferData.TransferID = req.TransferRequestID;
666
667 int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
668 byte[] chunk = new byte[chunkSize];
669 Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length);
670
671 TransferPacket.TransferData.Data = chunk;
672
673 // 0 indicates more packets to come, 1 indicates last packet
674 if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
675 {
676 TransferPacket.TransferData.Status = 0;
677 }
678 else
679 {
680 TransferPacket.TransferData.Status = 1;
681 }
682 TransferPacket.Header.Zerocoded = true;
683 req.RequestUser.OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
684
685 processedLength += chunkSize;
686 packetNumber++;
687 }
688 }
689 } 638 }
690 639
691 //remove requests that have been completed 640 //remove requests that have been completed