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 | |
parent | commit justin's grafitti board to the base OpenSim script (diff) | |
download | opensim-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
-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 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | 76 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs | 3 |
6 files changed, 165 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 | ||
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index ea2831c..b298578 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs | |||
@@ -6242,6 +6242,82 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
6242 | OutPacket(lsrp, ThrottleOutPacketType.Task); | 6242 | OutPacket(lsrp, ThrottleOutPacketType.Task); |
6243 | } | 6243 | } |
6244 | 6244 | ||
6245 | public void SendAsset(AssetRequestToClient req) | ||
6246 | { | ||
6247 | |||
6248 | //Console.WriteLine("sending asset " + req.RequestAssetID); | ||
6249 | TransferInfoPacket Transfer = new TransferInfoPacket(); | ||
6250 | Transfer.TransferInfo.ChannelType = 2; | ||
6251 | Transfer.TransferInfo.Status = 0; | ||
6252 | Transfer.TransferInfo.TargetType = 0; | ||
6253 | if (req.AssetRequestSource == 2) | ||
6254 | { | ||
6255 | Transfer.TransferInfo.Params = new byte[20]; | ||
6256 | Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); | ||
6257 | int assType = (int)req.AssetInf.Type; | ||
6258 | Array.Copy(Helpers.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4); | ||
6259 | } | ||
6260 | else if (req.AssetRequestSource == 3) | ||
6261 | { | ||
6262 | Transfer.TransferInfo.Params = req.Params; | ||
6263 | // Transfer.TransferInfo.Params = new byte[100]; | ||
6264 | //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16); | ||
6265 | //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16); | ||
6266 | } | ||
6267 | Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; | ||
6268 | Transfer.TransferInfo.TransferID = req.TransferRequestID; | ||
6269 | Transfer.Header.Zerocoded = true; | ||
6270 | OutPacket(Transfer, ThrottleOutPacketType.Asset); | ||
6271 | |||
6272 | if (req.NumPackets == 1) | ||
6273 | { | ||
6274 | TransferPacketPacket TransferPacket = new TransferPacketPacket(); | ||
6275 | TransferPacket.TransferData.Packet = 0; | ||
6276 | TransferPacket.TransferData.ChannelType = 2; | ||
6277 | TransferPacket.TransferData.TransferID = req.TransferRequestID; | ||
6278 | TransferPacket.TransferData.Data = req.AssetInf.Data; | ||
6279 | TransferPacket.TransferData.Status = 1; | ||
6280 | TransferPacket.Header.Zerocoded = true; | ||
6281 | OutPacket(TransferPacket, ThrottleOutPacketType.Asset); | ||
6282 | } | ||
6283 | else | ||
6284 | { | ||
6285 | int processedLength = 0; | ||
6286 | // libsecondlife hardcodes 1500 as the maximum data chunk size | ||
6287 | int maxChunkSize = 1250; | ||
6288 | int packetNumber = 0; | ||
6289 | |||
6290 | while (processedLength < req.AssetInf.Data.Length) | ||
6291 | { | ||
6292 | TransferPacketPacket TransferPacket = new TransferPacketPacket(); | ||
6293 | TransferPacket.TransferData.Packet = packetNumber; | ||
6294 | TransferPacket.TransferData.ChannelType = 2; | ||
6295 | TransferPacket.TransferData.TransferID = req.TransferRequestID; | ||
6296 | |||
6297 | int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize); | ||
6298 | byte[] chunk = new byte[chunkSize]; | ||
6299 | Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length); | ||
6300 | |||
6301 | TransferPacket.TransferData.Data = chunk; | ||
6302 | |||
6303 | // 0 indicates more packets to come, 1 indicates last packet | ||
6304 | if (req.AssetInf.Data.Length - processedLength > maxChunkSize) | ||
6305 | { | ||
6306 | TransferPacket.TransferData.Status = 0; | ||
6307 | } | ||
6308 | else | ||
6309 | { | ||
6310 | TransferPacket.TransferData.Status = 1; | ||
6311 | } | ||
6312 | TransferPacket.Header.Zerocoded = true; | ||
6313 | OutPacket(TransferPacket, ThrottleOutPacketType.Asset); | ||
6314 | |||
6315 | processedLength += chunkSize; | ||
6316 | packetNumber++; | ||
6317 | } | ||
6318 | } | ||
6319 | } | ||
6320 | |||
6245 | public ClientInfo GetClientInfo() | 6321 | public ClientInfo GetClientInfo() |
6246 | { | 6322 | { |
6247 | //MainLog.Instance.Verbose("CLIENT", "GetClientInfo BGN"); | 6323 | //MainLog.Instance.Verbose("CLIENT", "GetClientInfo BGN"); |
diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs index a64d857..4935672 100644 --- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs | |||
@@ -684,6 +684,10 @@ namespace OpenSim.Region.Environment.Modules.World.NPC | |||
684 | { | 684 | { |
685 | } | 685 | } |
686 | 686 | ||
687 | public void SendAsset(AssetRequestToClient req) | ||
688 | { | ||
689 | } | ||
690 | |||
687 | public void SetDebug(int newDebug) | 691 | public void SetDebug(int newDebug) |
688 | { | 692 | { |
689 | } | 693 | } |
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 99372fe..6ff600f 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs | |||
@@ -767,7 +767,10 @@ namespace OpenSim.Region.Examples.SimpleModule | |||
767 | 767 | ||
768 | public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia) | 768 | public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia) |
769 | { | 769 | { |
770 | } | ||
770 | 771 | ||
772 | public void SendAsset(AssetRequestToClient req) | ||
773 | { | ||
771 | } | 774 | } |
772 | } | 775 | } |
773 | } | 776 | } |