diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs | 41 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 39 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs | 53 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs | 160 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2 | bin | 0 -> 24410 bytes |
5 files changed, 274 insertions, 19 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs index 8aa2ff3..3995620 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs | |||
@@ -45,6 +45,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
45 | private const int IMAGE_PACKET_SIZE = 1000; | 45 | private const int IMAGE_PACKET_SIZE = 1000; |
46 | private const int FIRST_PACKET_SIZE = 600; | 46 | private const int FIRST_PACKET_SIZE = 600; |
47 | 47 | ||
48 | /// <summary> | ||
49 | /// If we've requested an asset but not received it in this ticks timeframe, then allow a duplicate | ||
50 | /// request from the client to trigger a fresh asset request. | ||
51 | /// </summary> | ||
52 | /// <remarks> | ||
53 | /// There are 10,000 ticks in a millisecond | ||
54 | /// </remarks> | ||
55 | private const int ASSET_REQUEST_TIMEOUT = 100000000; | ||
56 | |||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 58 | ||
50 | public uint LastSequence; | 59 | public uint LastSequence; |
@@ -57,8 +66,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
57 | public UUID AgentID; | 66 | public UUID AgentID; |
58 | public IInventoryAccessModule InventoryAccessModule; | 67 | public IInventoryAccessModule InventoryAccessModule; |
59 | private OpenJPEG.J2KLayerInfo[] m_layers; | 68 | private OpenJPEG.J2KLayerInfo[] m_layers; |
69 | |||
70 | /// <summary> | ||
71 | /// Has this request decoded the asset data? | ||
72 | /// </summary> | ||
60 | public bool IsDecoded { get; private set; } | 73 | public bool IsDecoded { get; private set; } |
74 | |||
75 | /// <summary> | ||
76 | /// Has this request received the required asset data? | ||
77 | /// </summary> | ||
61 | public bool HasAsset { get; private set; } | 78 | public bool HasAsset { get; private set; } |
79 | |||
80 | /// <summary> | ||
81 | /// Time in milliseconds at which the asset was requested. | ||
82 | /// </summary> | ||
83 | public long AssetRequestTime { get; private set; } | ||
84 | |||
62 | public C5.IPriorityQueueHandle<J2KImage> PriorityQueueHandle; | 85 | public C5.IPriorityQueueHandle<J2KImage> PriorityQueueHandle; |
63 | 86 | ||
64 | private uint m_currentPacket; | 87 | private uint m_currentPacket; |
@@ -82,7 +105,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
82 | /// <param name="packetsToSend">Maximum number of packets to send during this call</param> | 105 | /// <param name="packetsToSend">Maximum number of packets to send during this call</param> |
83 | /// <param name="packetsSent">Number of packets sent during this call</param> | 106 | /// <param name="packetsSent">Number of packets sent during this call</param> |
84 | /// <returns>True if the transfer completes at the current discard level, otherwise false</returns> | 107 | /// <returns>True if the transfer completes at the current discard level, otherwise false</returns> |
85 | public bool SendPackets(LLClientView client, int packetsToSend, out int packetsSent) | 108 | public bool SendPackets(IClientAPI client, int packetsToSend, out int packetsSent) |
86 | { | 109 | { |
87 | packetsSent = 0; | 110 | packetsSent = 0; |
88 | 111 | ||
@@ -123,10 +146,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
123 | { | 146 | { |
124 | if (!HasAsset) | 147 | if (!HasAsset) |
125 | { | 148 | { |
126 | if (!m_assetRequested) | 149 | if (!m_assetRequested || DateTime.UtcNow.Ticks > AssetRequestTime + ASSET_REQUEST_TIMEOUT) |
127 | { | 150 | { |
151 | // m_log.DebugFormat( | ||
152 | // "[J2KIMAGE]: Requesting asset {0} from request in packet {1}, already requested? {2}, due to timeout? {3}", | ||
153 | // TextureID, LastSequence, m_assetRequested, DateTime.UtcNow.Ticks > AssetRequestTime + ASSET_REQUEST_TIMEOUT); | ||
154 | |||
128 | m_assetRequested = true; | 155 | m_assetRequested = true; |
129 | // m_log.DebugFormat("[J2KIMAGE]: Requesting asset {0}", TextureID); | 156 | AssetRequestTime = DateTime.UtcNow.Ticks; |
157 | |||
130 | AssetService.Get(TextureID.ToString(), this, AssetReceived); | 158 | AssetService.Get(TextureID.ToString(), this, AssetReceived); |
131 | } | 159 | } |
132 | } | 160 | } |
@@ -215,7 +243,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
215 | } | 243 | } |
216 | } | 244 | } |
217 | 245 | ||
218 | private bool SendFirstPacket(LLClientView client) | 246 | private bool SendFirstPacket(IClientAPI client) |
219 | { | 247 | { |
220 | if (client == null) | 248 | if (client == null) |
221 | return false; | 249 | return false; |
@@ -250,7 +278,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
250 | return false; | 278 | return false; |
251 | } | 279 | } |
252 | 280 | ||
253 | private bool SendPacket(LLClientView client) | 281 | private bool SendPacket(IClientAPI client) |
254 | { | 282 | { |
255 | if (client == null) | 283 | if (client == null) |
256 | return false; | 284 | return false; |
@@ -380,6 +408,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
380 | 408 | ||
381 | private void AssetReceived(string id, Object sender, AssetBase asset) | 409 | private void AssetReceived(string id, Object sender, AssetBase asset) |
382 | { | 410 | { |
411 | // m_log.DebugFormat( | ||
412 | // "[J2KIMAGE]: Received asset {0} ({1} bytes)", id, asset != null ? asset.Data.Length.ToString() : "n/a"); | ||
413 | |||
383 | UUID assetID = UUID.Zero; | 414 | UUID assetID = UUID.Zero; |
384 | if (asset != null) | 415 | if (asset != null) |
385 | { | 416 | { |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 01e1383..d9dc6b7 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -220,6 +220,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
220 | public event BakeTerrain OnBakeTerrain; | 220 | public event BakeTerrain OnBakeTerrain; |
221 | public event RequestTerrain OnUploadTerrain; | 221 | public event RequestTerrain OnUploadTerrain; |
222 | public event EstateChangeInfo OnEstateChangeInfo; | 222 | public event EstateChangeInfo OnEstateChangeInfo; |
223 | public event EstateManageTelehub OnEstateManageTelehub; | ||
223 | public event EstateRestartSimRequest OnEstateRestartSimRequest; | 224 | public event EstateRestartSimRequest OnEstateRestartSimRequest; |
224 | public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest; | 225 | public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest; |
225 | public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest; | 226 | public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest; |
@@ -4537,6 +4538,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4537 | OutPacket(packet, ThrottleOutPacketType.Task); | 4538 | OutPacket(packet, ThrottleOutPacketType.Task); |
4538 | } | 4539 | } |
4539 | 4540 | ||
4541 | public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint) | ||
4542 | { | ||
4543 | TelehubInfoPacket packet = (TelehubInfoPacket)PacketPool.Instance.GetPacket(PacketType.TelehubInfo); | ||
4544 | packet.TelehubBlock.ObjectID = ObjectID; | ||
4545 | packet.TelehubBlock.ObjectName = Utils.StringToBytes(ObjectName); | ||
4546 | packet.TelehubBlock.TelehubPos = ObjectPos; | ||
4547 | packet.TelehubBlock.TelehubRot = ObjectRot; | ||
4548 | |||
4549 | packet.SpawnPointBlock = new TelehubInfoPacket.SpawnPointBlockBlock[SpawnPoint.Count]; | ||
4550 | for (int n = 0; n < SpawnPoint.Count; n++) | ||
4551 | { | ||
4552 | packet.SpawnPointBlock[n] = new TelehubInfoPacket.SpawnPointBlockBlock{SpawnPointPos = SpawnPoint[n]}; | ||
4553 | } | ||
4554 | |||
4555 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
4556 | } | ||
4557 | |||
4540 | #endregion | 4558 | #endregion |
4541 | 4559 | ||
4542 | #region Land Data Sending Methods | 4560 | #region Land Data Sending Methods |
@@ -8981,7 +8999,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
8981 | private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack) | 8999 | private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack) |
8982 | { | 9000 | { |
8983 | EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; | 9001 | EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; |
8984 | //m_log.Debug(messagePacket.ToString()); | 9002 | // m_log.InfoFormat("[LLCLIENTVIEW]: Packet: {0}", Utils.BytesToString(messagePacket.MethodData.Method)); |
8985 | GodLandStatRequest handlerLandStatRequest; | 9003 | GodLandStatRequest handlerLandStatRequest; |
8986 | 9004 | ||
8987 | #region Packet Session and User Check | 9005 | #region Packet Session and User Check |
@@ -9280,6 +9298,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9280 | } | 9298 | } |
9281 | return true; | 9299 | return true; |
9282 | 9300 | ||
9301 | case "telehub": | ||
9302 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | ||
9303 | { | ||
9304 | UUID invoice = messagePacket.MethodData.Invoice; | ||
9305 | UUID SenderID = messagePacket.AgentData.AgentID; | ||
9306 | UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter)); | ||
9307 | |||
9308 | string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter); | ||
9309 | |||
9310 | EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub; | ||
9311 | if (handlerEstateManageTelehub != null) | ||
9312 | { | ||
9313 | handlerEstateManageTelehub(this, invoice, SenderID, command, param1); | ||
9314 | } | ||
9315 | } | ||
9316 | return true; | ||
9317 | |||
9283 | default: | 9318 | default: |
9284 | m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket); | 9319 | m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket); |
9285 | return true; | 9320 | return true; |
@@ -9291,8 +9326,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9291 | //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts | 9326 | //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts |
9292 | //lsrp.RequestData.RequestFlags; | 9327 | //lsrp.RequestData.RequestFlags; |
9293 | //lsrp.RequestData.Filter; | 9328 | //lsrp.RequestData.Filter; |
9294 | |||
9295 | // return true; | ||
9296 | } | 9329 | } |
9297 | 9330 | ||
9298 | private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack) | 9331 | private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack) |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs index db428f1..073c357 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs | |||
@@ -55,18 +55,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
56 | private bool m_shuttingdown; | 56 | private bool m_shuttingdown; |
57 | private AssetBase m_missingImage; | 57 | private AssetBase m_missingImage; |
58 | private LLClientView m_client; //Client we're assigned to | 58 | private IAssetService m_assetCache; |
59 | private IAssetService m_assetCache; //Asset Cache | 59 | private IJ2KDecoder m_j2kDecodeModule; |
60 | private IJ2KDecoder m_j2kDecodeModule; //Our J2K module | 60 | |
61 | /// <summary> | ||
62 | /// Priority queue for determining which image to send first. | ||
63 | /// </summary> | ||
61 | private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); | 64 | private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); |
65 | |||
66 | /// <summary> | ||
67 | /// Used to control thread access to the priority queue. | ||
68 | /// </summary> | ||
62 | private object m_syncRoot = new object(); | 69 | private object m_syncRoot = new object(); |
63 | 70 | ||
64 | public LLClientView Client { get { return m_client; } } | 71 | /// <summary> |
72 | /// Client served by this image manager | ||
73 | /// </summary> | ||
74 | public IClientAPI Client { get; private set; } | ||
75 | |||
65 | public AssetBase MissingImage { get { return m_missingImage; } } | 76 | public AssetBase MissingImage { get { return m_missingImage; } } |
66 | 77 | ||
67 | public LLImageManager(LLClientView client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule) | 78 | public LLImageManager(IClientAPI client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule) |
68 | { | 79 | { |
69 | m_client = client; | 80 | Client = client; |
70 | m_assetCache = pAssetCache; | 81 | m_assetCache = pAssetCache; |
71 | 82 | ||
72 | if (pAssetCache != null) | 83 | if (pAssetCache != null) |
@@ -111,8 +122,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
111 | // "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}", | 122 | // "[LL IMAGE MANAGER]: Received duplicate of existing request for {0}, start packet {1} from {2}", |
112 | // newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); | 123 | // newRequest.RequestedAssetID, newRequest.PacketNumber, m_client.Name); |
113 | 124 | ||
114 | //m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}", | 125 | // m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}", |
115 | // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); | 126 | // newRequest.RequestedAssetID, newRequest.DiscardLevel, newRequest.PacketNumber, newRequest.Priority); |
116 | 127 | ||
117 | //Check the packet sequence to make sure this isn't older than | 128 | //Check the packet sequence to make sure this isn't older than |
118 | //one we've already received | 129 | //one we've already received |
@@ -178,8 +189,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
178 | imgrequest = new J2KImage(this); | 189 | imgrequest = new J2KImage(this); |
179 | imgrequest.J2KDecoder = m_j2kDecodeModule; | 190 | imgrequest.J2KDecoder = m_j2kDecodeModule; |
180 | imgrequest.AssetService = m_assetCache; | 191 | imgrequest.AssetService = m_assetCache; |
181 | imgrequest.AgentID = m_client.AgentId; | 192 | imgrequest.AgentID = Client.AgentId; |
182 | imgrequest.InventoryAccessModule = m_client.Scene.RequestModuleInterface<IInventoryAccessModule>(); | 193 | imgrequest.InventoryAccessModule = Client.Scene.RequestModuleInterface<IInventoryAccessModule>(); |
183 | imgrequest.DiscardLevel = newRequest.DiscardLevel; | 194 | imgrequest.DiscardLevel = newRequest.DiscardLevel; |
184 | imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); | 195 | imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); |
185 | imgrequest.Priority = newRequest.Priority; | 196 | imgrequest.Priority = newRequest.Priority; |
@@ -210,7 +221,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
210 | if (image.IsDecoded) | 221 | if (image.IsDecoded) |
211 | { | 222 | { |
212 | int sent; | 223 | int sent; |
213 | bool imageDone = image.SendPackets(m_client, packetsToSend - packetsSent, out sent); | 224 | bool imageDone = image.SendPackets(Client, packetsToSend - packetsSent, out sent); |
214 | packetsSent += sent; | 225 | packetsSent += sent; |
215 | 226 | ||
216 | // If the send is complete, destroy any knowledge of this transfer | 227 | // If the send is complete, destroy any knowledge of this transfer |
@@ -246,6 +257,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
246 | } | 257 | } |
247 | 258 | ||
248 | /// <summary> | 259 | /// <summary> |
260 | /// Clear the image queue. | ||
261 | /// </summary> | ||
262 | /// <returns>The number of requests cleared.</returns> | ||
263 | public int ClearImageQueue() | ||
264 | { | ||
265 | int requestsDeleted; | ||
266 | |||
267 | lock (m_priorityQueue) | ||
268 | { | ||
269 | requestsDeleted = m_priorityQueue.Count; | ||
270 | |||
271 | // Surprisingly, there doesn't seem to be a clear method at this time. | ||
272 | while (!m_priorityQueue.IsEmpty) | ||
273 | m_priorityQueue.DeleteMax(); | ||
274 | } | ||
275 | |||
276 | return requestsDeleted; | ||
277 | } | ||
278 | |||
279 | /// <summary> | ||
249 | /// Returns an array containing all the images in the queue. | 280 | /// Returns an array containing all the images in the queue. |
250 | /// </summary> | 281 | /// </summary> |
251 | /// <returns></returns> | 282 | /// <returns></returns> |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs new file mode 100644 index 0000000..1b68d68 --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs | |||
@@ -0,0 +1,160 @@ | |||
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 OpenSimulator 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.IO; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | using log4net.Config; | ||
33 | using Nini.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.Packets; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Region.CoreModules.Agent.TextureSender; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using OpenSim.Tests.Common; | ||
41 | using OpenSim.Tests.Common.Mock; | ||
42 | |||
43 | namespace OpenSim.Region.ClientStack.LindenUDP.Tests | ||
44 | { | ||
45 | [TestFixture] | ||
46 | public class LLImageManagerTests | ||
47 | { | ||
48 | private AssetBase m_testImageAsset; | ||
49 | private Scene scene; | ||
50 | private LLImageManager llim; | ||
51 | private TestClient tc; | ||
52 | |||
53 | [TestFixtureSetUp] | ||
54 | public void FixtureInit() | ||
55 | { | ||
56 | using ( | ||
57 | Stream resource | ||
58 | = GetType().Assembly.GetManifestResourceStream( | ||
59 | "OpenSim.Region.ClientStack.LindenUDP.Tests.Resources.4-tile2.jp2")) | ||
60 | { | ||
61 | using (BinaryReader br = new BinaryReader(resource)) | ||
62 | { | ||
63 | m_testImageAsset | ||
64 | = new AssetBase( | ||
65 | TestHelpers.ParseTail(0x1), | ||
66 | "Test Image", | ||
67 | (sbyte)AssetType.Texture, | ||
68 | TestHelpers.ParseTail(0x2).ToString()); | ||
69 | |||
70 | m_testImageAsset.Data = br.ReadBytes(99999999); | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | |||
75 | [SetUp] | ||
76 | public void SetUp() | ||
77 | { | ||
78 | UUID userId = TestHelpers.ParseTail(0x3); | ||
79 | |||
80 | J2KDecoderModule j2kdm = new J2KDecoderModule(); | ||
81 | |||
82 | scene = SceneHelpers.SetupScene(); | ||
83 | SceneHelpers.SetupSceneModules(scene, j2kdm); | ||
84 | |||
85 | tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); | ||
86 | llim = new LLImageManager(tc, scene.AssetService, j2kdm); | ||
87 | } | ||
88 | |||
89 | [Test] | ||
90 | public void TestSendImage() | ||
91 | { | ||
92 | TestHelpers.InMethod(); | ||
93 | // XmlConfigurator.Configure(); | ||
94 | |||
95 | scene.AssetService.Store(m_testImageAsset); | ||
96 | |||
97 | TextureRequestArgs args = new TextureRequestArgs(); | ||
98 | args.RequestedAssetID = m_testImageAsset.FullID; | ||
99 | args.DiscardLevel = 0; | ||
100 | args.PacketNumber = 1; | ||
101 | args.Priority = 5; | ||
102 | args.requestSequence = 1; | ||
103 | |||
104 | llim.EnqueueReq(args); | ||
105 | llim.ProcessImageQueue(20); | ||
106 | |||
107 | Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(1)); | ||
108 | } | ||
109 | |||
110 | [Test] | ||
111 | public void TestDiscardImage() | ||
112 | { | ||
113 | TestHelpers.InMethod(); | ||
114 | // XmlConfigurator.Configure(); | ||
115 | |||
116 | scene.AssetService.Store(m_testImageAsset); | ||
117 | |||
118 | TextureRequestArgs args = new TextureRequestArgs(); | ||
119 | args.RequestedAssetID = m_testImageAsset.FullID; | ||
120 | args.DiscardLevel = 0; | ||
121 | args.PacketNumber = 1; | ||
122 | args.Priority = 5; | ||
123 | args.requestSequence = 1; | ||
124 | llim.EnqueueReq(args); | ||
125 | |||
126 | // Now create a discard request | ||
127 | TextureRequestArgs discardArgs = new TextureRequestArgs(); | ||
128 | discardArgs.RequestedAssetID = m_testImageAsset.FullID; | ||
129 | discardArgs.DiscardLevel = -1; | ||
130 | discardArgs.PacketNumber = 1; | ||
131 | discardArgs.Priority = 0; | ||
132 | discardArgs.requestSequence = 2; | ||
133 | llim.EnqueueReq(discardArgs); | ||
134 | |||
135 | llim.ProcessImageQueue(20); | ||
136 | |||
137 | Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0)); | ||
138 | } | ||
139 | |||
140 | [Test] | ||
141 | public void TestMissingImage() | ||
142 | { | ||
143 | TestHelpers.InMethod(); | ||
144 | // XmlConfigurator.Configure(); | ||
145 | |||
146 | TextureRequestArgs args = new TextureRequestArgs(); | ||
147 | args.RequestedAssetID = m_testImageAsset.FullID; | ||
148 | args.DiscardLevel = 0; | ||
149 | args.PacketNumber = 1; | ||
150 | args.Priority = 5; | ||
151 | args.requestSequence = 1; | ||
152 | |||
153 | llim.EnqueueReq(args); | ||
154 | llim.ProcessImageQueue(20); | ||
155 | |||
156 | Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0)); | ||
157 | Assert.That(tc.SentImageNotInDatabasePackets.Count, Is.EqualTo(1)); | ||
158 | } | ||
159 | } | ||
160 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2 b/OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2 new file mode 100644 index 0000000..8c63104 --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2 | |||
Binary files differ | |||