aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/UserTextureDownloadService.cs
diff options
context:
space:
mode:
authorJeff Ames2008-01-03 13:44:52 +0000
committerJeff Ames2008-01-03 13:44:52 +0000
commit119f9b0d8027324b3991fec302ea6c6210b8df46 (patch)
tree46575f880167e2082b4acc53c4501723b7afba22 /OpenSim/Region/Environment/Modules/UserTextureDownloadService.cs
parent* Some work on TextureDownloadModule (diff)
downloadopensim-SC_OLD-119f9b0d8027324b3991fec302ea6c6210b8df46.zip
opensim-SC_OLD-119f9b0d8027324b3991fec302ea6c6210b8df46.tar.gz
opensim-SC_OLD-119f9b0d8027324b3991fec302ea6c6210b8df46.tar.bz2
opensim-SC_OLD-119f9b0d8027324b3991fec302ea6c6210b8df46.tar.xz
Set svn:eol-style.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/UserTextureDownloadService.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/UserTextureDownloadService.cs194
1 files changed, 97 insertions, 97 deletions
diff --git a/OpenSim/Region/Environment/Modules/UserTextureDownloadService.cs b/OpenSim/Region/Environment/Modules/UserTextureDownloadService.cs
index 6ee43e2..9a5b362 100644
--- a/OpenSim/Region/Environment/Modules/UserTextureDownloadService.cs
+++ b/OpenSim/Region/Environment/Modules/UserTextureDownloadService.cs
@@ -1,98 +1,98 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using libsecondlife; 3using libsecondlife;
4using OpenSim.Framework; 4using OpenSim.Framework;
5using OpenSim.Framework.Console; 5using OpenSim.Framework.Console;
6using OpenSim.Region.Environment.Scenes; 6using OpenSim.Region.Environment.Scenes;
7 7
8namespace OpenSim.Region.Environment.Modules 8namespace OpenSim.Region.Environment.Modules
9{ 9{
10 public class UserTextureDownloadService 10 public class UserTextureDownloadService
11 { 11 {
12 private readonly Dictionary<LLUUID, TextureSender> m_textureSenders = new Dictionary<LLUUID, TextureSender>(); 12 private readonly Dictionary<LLUUID, TextureSender> m_textureSenders = new Dictionary<LLUUID, TextureSender>();
13 private readonly BlockingQueue<TextureSender> m_sharedSendersQueue; 13 private readonly BlockingQueue<TextureSender> m_sharedSendersQueue;
14 private readonly Scene m_scene; 14 private readonly Scene m_scene;
15 15
16 public UserTextureDownloadService(Scene scene, BlockingQueue<TextureSender> sharedQueue) 16 public UserTextureDownloadService(Scene scene, BlockingQueue<TextureSender> sharedQueue)
17 { 17 {
18 m_scene = scene; 18 m_scene = scene;
19 m_sharedSendersQueue = sharedQueue; 19 m_sharedSendersQueue = sharedQueue;
20 } 20 }
21 21
22 public void HandleTextureRequest(IClientAPI client, TextureRequestArgs e) 22 public void HandleTextureRequest(IClientAPI client, TextureRequestArgs e)
23 { 23 {
24 TextureSender textureSender; 24 TextureSender textureSender;
25 25
26 //TODO: should be working out the data size/ number of packets to be sent for each discard level 26 //TODO: should be working out the data size/ number of packets to be sent for each discard level
27 if ((e.DiscardLevel >= 0) || (e.Priority != 0)) 27 if ((e.DiscardLevel >= 0) || (e.Priority != 0))
28 { 28 {
29 lock (m_textureSenders) 29 lock (m_textureSenders)
30 { 30 {
31 if (m_textureSenders.TryGetValue(e.RequestedAssetID, out textureSender)) 31 if (m_textureSenders.TryGetValue(e.RequestedAssetID, out textureSender))
32 { 32 {
33 textureSender.UpdateRequest(e.DiscardLevel, e.PacketNumber); 33 textureSender.UpdateRequest(e.DiscardLevel, e.PacketNumber);
34 34
35 if ((textureSender.ImageLoaded) && 35 if ((textureSender.ImageLoaded) &&
36 (textureSender.Sending == false)) 36 (textureSender.Sending == false))
37 { 37 {
38 EnqueueTextureSender(textureSender); 38 EnqueueTextureSender(textureSender);
39 } 39 }
40 } 40 }
41 else 41 else
42 { 42 {
43 TextureSender requestHandler = 43 TextureSender requestHandler =
44 new TextureSender(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber); 44 new TextureSender(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber);
45 m_textureSenders.Add(e.RequestedAssetID, requestHandler); 45 m_textureSenders.Add(e.RequestedAssetID, requestHandler);
46 m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback); 46 m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback);
47 } 47 }
48 } 48 }
49 } 49 }
50 else 50 else
51 { 51 {
52 lock (m_textureSenders) 52 lock (m_textureSenders)
53 { 53 {
54 if (m_textureSenders.TryGetValue(e.RequestedAssetID, out textureSender)) 54 if (m_textureSenders.TryGetValue(e.RequestedAssetID, out textureSender))
55 { 55 {
56 textureSender.Cancel = true; 56 textureSender.Cancel = true;
57 } 57 }
58 } 58 }
59 } 59 }
60 } 60 }
61 61
62 public void TextureCallback(LLUUID textureID, AssetBase asset) 62 public void TextureCallback(LLUUID textureID, AssetBase asset)
63 { 63 {
64 lock (m_textureSenders) 64 lock (m_textureSenders)
65 { 65 {
66 TextureSender textureSender; 66 TextureSender textureSender;
67 67
68 if (m_textureSenders.TryGetValue(textureID, out textureSender)) 68 if (m_textureSenders.TryGetValue(textureID, out textureSender))
69 { 69 {
70 if (!textureSender.ImageLoaded) 70 if (!textureSender.ImageLoaded)
71 { 71 {
72 textureSender.TextureReceived(asset); 72 textureSender.TextureReceived(asset);
73 73
74 EnqueueTextureSender(textureSender); 74 EnqueueTextureSender(textureSender);
75 } 75 }
76 } 76 }
77 else 77 else
78 { 78 {
79 throw new Exception("Got a texture with no sender object to handle it, this shouldn't happen"); 79 throw new Exception("Got a texture with no sender object to handle it, this shouldn't happen");
80 } 80 }
81 } 81 }
82 } 82 }
83 83
84 private void EnqueueTextureSender(TextureSender textureSender) 84 private void EnqueueTextureSender(TextureSender textureSender)
85 { 85 {
86 MainLog.Instance.Debug( "TEXTUREDOWNLOAD", "Start: ["+textureSender.RequestedAssetID+"] to ["+textureSender.RequestUser.Name+"]"); 86 MainLog.Instance.Debug( "TEXTUREDOWNLOAD", "Start: ["+textureSender.RequestedAssetID+"] to ["+textureSender.RequestUser.Name+"]");
87 87
88 textureSender.Cancel = false; 88 textureSender.Cancel = false;
89 textureSender.Sending = true; 89 textureSender.Sending = true;
90 textureSender.counter = 0; 90 textureSender.counter = 0;
91 91
92 if (!m_sharedSendersQueue.Contains(textureSender)) 92 if (!m_sharedSendersQueue.Contains(textureSender))
93 { 93 {
94 m_sharedSendersQueue.Enqueue(textureSender); 94 m_sharedSendersQueue.Enqueue(textureSender);
95 } 95 }
96 } 96 }
97 } 97 }
98} \ No newline at end of file 98} \ No newline at end of file