diff options
author | Teravus Ovares | 2008-06-18 23:04:15 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-06-18 23:04:15 +0000 |
commit | cb29926e3cefedd9bea3c26b1b7f079c8209f6fa (patch) | |
tree | bbf08176c4257299b825d899960f750266b4df1a /OpenSim/Framework | |
parent | commit justin's grafitti board to the base OpenSim script (diff) | |
download | opensim-SC-cb29926e3cefedd9bea3c26b1b7f079c8209f6fa.zip opensim-SC-cb29926e3cefedd9bea3c26b1b7f079c8209f6fa.tar.gz opensim-SC-cb29926e3cefedd9bea3c26b1b7f079c8209f6fa.tar.bz2 opensim-SC-cb29926e3cefedd9bea3c26b1b7f079c8209f6fa.tar.xz |
* Refactors call to OutPacket out of AssetCache and into LLClientView
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/AssetRequestToClient.cs | 63 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetCache.cs | 85 | ||||
-rw-r--r-- | OpenSim/Framework/IClientAPI.cs | 2 |
3 files changed, 82 insertions, 68 deletions
diff --git a/OpenSim/Framework/AssetRequestToClient.cs b/OpenSim/Framework/AssetRequestToClient.cs new file mode 100644 index 0000000..916b9f5 --- /dev/null +++ b/OpenSim/Framework/AssetRequestToClient.cs | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | |||
33 | namespace OpenSim.Framework | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// This class was created to refactor OutPacket out of AssetCache | ||
37 | /// There is a conflict between | ||
38 | /// OpenSim.Framework.Communications.Cache.AssetRequest and OpenSim.Framework.AssetRequest | ||
39 | /// and unifying them results in a prebuild chicken and egg problem with OpenSim.Framework requiring | ||
40 | /// OpenSim.Framework.Communications.Cache while OpenSim.Framework.Communications.Cache | ||
41 | /// requiring OpenSim.Framework | ||
42 | /// </summary> | ||
43 | public class AssetRequestToClient | ||
44 | { | ||
45 | public LLUUID RequestAssetID; | ||
46 | public AssetBase AssetInf; | ||
47 | public AssetBase ImageInfo; | ||
48 | public LLUUID TransferRequestID; | ||
49 | public long DataPointer = 0; | ||
50 | public int NumPackets = 0; | ||
51 | public int PacketCounter = 0; | ||
52 | public bool IsTextureRequest; | ||
53 | public byte AssetRequestSource = 2; | ||
54 | public byte[] Params = null; | ||
55 | //public bool AssetInCache; | ||
56 | //public int TimeRequested; | ||
57 | public int DiscardLevel = -1; | ||
58 | |||
59 | public AssetRequestToClient() | ||
60 | { | ||
61 | } | ||
62 | } | ||
63 | } | ||
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 |
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 11cc166..fafd31d 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs | |||
@@ -1011,6 +1011,8 @@ namespace OpenSim.Framework | |||
1011 | 1011 | ||
1012 | void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia); | 1012 | void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia); |
1013 | 1013 | ||
1014 | void SendAsset(AssetRequestToClient req); | ||
1015 | |||
1014 | byte[] GetThrottlesPacked(float multiplier); | 1016 | byte[] GetThrottlesPacked(float multiplier); |
1015 | 1017 | ||
1016 | 1018 | ||