aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/TextureDownloadModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/TextureDownloadModule.cs49
1 files changed, 23 insertions, 26 deletions
diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
index 5eeeca6..66c499b 100644
--- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
@@ -27,14 +27,12 @@
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Threading;
31using libsecondlife; 30using libsecondlife;
32using libsecondlife.Packets; 31using libsecondlife.Packets;
33using OpenSim.Framework.Interfaces; 32using Nini.Config;
34using OpenSim.Framework; 33using OpenSim.Framework;
35using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
37using Nini.Config;
38 36
39namespace OpenSim.Region.Environment.Modules 37namespace OpenSim.Region.Environment.Modules
40{ 38{
@@ -42,17 +40,19 @@ namespace OpenSim.Region.Environment.Modules
42 { 40 {
43 private Scene m_scene; 41 private Scene m_scene;
44 private List<Scene> m_scenes = new List<Scene>(); 42 private List<Scene> m_scenes = new List<Scene>();
45 private Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>> ClientRequests = new Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>>(); 43
44 private Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>> ClientRequests =
45 new Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>>();
46 46
47 private BlockingQueue<TextureSender> QueueSenders = new BlockingQueue<TextureSender>(); 47 private BlockingQueue<TextureSender> QueueSenders = new BlockingQueue<TextureSender>();
48 private Dictionary<LLUUID, List<LLUUID>> InProcess = new Dictionary<LLUUID, List<LLUUID>>(); 48 private Dictionary<LLUUID, List<LLUUID>> InProcess = new Dictionary<LLUUID, List<LLUUID>>();
49 // private Thread m_thread; 49 // private Thread m_thread;
50 50
51 public TextureDownloadModule() 51 public TextureDownloadModule()
52 { 52 {
53 // m_thread = new Thread(new ThreadStart(ProcessTextureSenders)); 53 // m_thread = new Thread(new ThreadStart(ProcessTextureSenders));
54 // m_thread.IsBackground = true; 54 // m_thread.IsBackground = true;
55 // m_thread.Start(); 55 // m_thread.Start();
56 } 56 }
57 57
58 public void Initialise(Scene scene, IConfigSource config) 58 public void Initialise(Scene scene, IConfigSource config)
@@ -85,7 +85,7 @@ namespace OpenSim.Region.Environment.Modules
85 85
86 public void NewClient(IClientAPI client) 86 public void NewClient(IClientAPI client)
87 { 87 {
88 /* lock (ClientRequests) 88 /* lock (ClientRequests)
89 { 89 {
90 if (!ClientRequests.ContainsKey(client.AgentId)) 90 if (!ClientRequests.ContainsKey(client.AgentId))
91 { 91 {
@@ -120,7 +120,7 @@ namespace OpenSim.Region.Environment.Modules
120 120
121 public void TextureRequest(Object sender, TextureRequestArgs e) 121 public void TextureRequest(Object sender, TextureRequestArgs e)
122 { 122 {
123 IClientAPI client = (IClientAPI)sender; 123 IClientAPI client = (IClientAPI) sender;
124 if (!ClientRequests[client.AgentId].ContainsKey(e.RequestedAssetID)) 124 if (!ClientRequests[client.AgentId].ContainsKey(e.RequestedAssetID))
125 { 125 {
126 lock (ClientRequests) 126 lock (ClientRequests)
@@ -136,15 +136,15 @@ namespace OpenSim.Region.Environment.Modules
136 { 136 {
137 while (true) 137 while (true)
138 { 138 {
139 TextureSender sender = this.QueueSenders.Dequeue(); 139 TextureSender sender = QueueSenders.Dequeue();
140 bool finished = sender.SendTexture(); 140 bool finished = sender.SendTexture();
141 if (finished) 141 if (finished)
142 { 142 {
143 this.TextureSent(sender); 143 TextureSent(sender);
144 } 144 }
145 else 145 else
146 { 146 {
147 this.QueueSenders.Enqueue(sender); 147 QueueSenders.Enqueue(sender);
148 } 148 }
149 } 149 }
150 } 150 }
@@ -173,13 +173,13 @@ namespace OpenSim.Region.Environment.Modules
173 173
174 if (asset.Data.LongLength > 600) 174 if (asset.Data.LongLength > 600)
175 { 175 {
176 NumPackets = 2 + (int)(asset.Data.Length - 601) / 1000; 176 NumPackets = 2 + (int) (asset.Data.Length - 601)/1000;
177 } 177 }
178 else 178 else
179 { 179 {
180 NumPackets = 1; 180 NumPackets = 1;
181 } 181 }
182 182
183 PacketCounter = (int) req.PacketNumber; 183 PacketCounter = (int) req.PacketNumber;
184 } 184 }
185 185
@@ -205,7 +205,7 @@ namespace OpenSim.Region.Environment.Modules
205 im.Header.Reliable = false; 205 im.Header.Reliable = false;
206 im.ImageID.Packets = 1; 206 im.ImageID.Packets = 1;
207 im.ImageID.ID = m_asset.FullID; 207 im.ImageID.ID = m_asset.FullID;
208 im.ImageID.Size = (uint)m_asset.Data.Length; 208 im.ImageID.Size = (uint) m_asset.Data.Length;
209 im.ImageData.Data = m_asset.Data; 209 im.ImageData.Data = m_asset.Data;
210 im.ImageID.Codec = 2; 210 im.ImageID.Codec = 2;
211 req.RequestUser.OutPacket(im); 211 req.RequestUser.OutPacket(im);
@@ -215,9 +215,9 @@ namespace OpenSim.Region.Environment.Modules
215 { 215 {
216 ImageDataPacket im = new ImageDataPacket(); 216 ImageDataPacket im = new ImageDataPacket();
217 im.Header.Reliable = false; 217 im.Header.Reliable = false;
218 im.ImageID.Packets = (ushort)(NumPackets); 218 im.ImageID.Packets = (ushort) (NumPackets);
219 im.ImageID.ID = m_asset.FullID; 219 im.ImageID.ID = m_asset.FullID;
220 im.ImageID.Size = (uint)m_asset.Data.Length; 220 im.ImageID.Size = (uint) m_asset.Data.Length;
221 im.ImageData.Data = new byte[600]; 221 im.ImageData.Data = new byte[600];
222 Array.Copy(m_asset.Data, 0, im.ImageData.Data, 0, 600); 222 Array.Copy(m_asset.Data, 0, im.ImageData.Data, 0, 600);
223 im.ImageID.Codec = 2; 223 im.ImageID.Codec = 2;
@@ -229,18 +229,16 @@ namespace OpenSim.Region.Environment.Modules
229 { 229 {
230 ImagePacketPacket im = new ImagePacketPacket(); 230 ImagePacketPacket im = new ImagePacketPacket();
231 im.Header.Reliable = false; 231 im.Header.Reliable = false;
232 im.ImageID.Packet = (ushort)(PacketCounter); 232 im.ImageID.Packet = (ushort) (PacketCounter);
233 im.ImageID.ID = m_asset.FullID; 233 im.ImageID.ID = m_asset.FullID;
234 int size = m_asset.Data.Length - 600 - (1000 * (PacketCounter - 1)); 234 int size = m_asset.Data.Length - 600 - (1000*(PacketCounter - 1));
235 if (size > 1000) size = 1000; 235 if (size > 1000) size = 1000;
236 im.ImageData.Data = new byte[size]; 236 im.ImageData.Data = new byte[size];
237 Array.Copy(m_asset.Data, 600 + (1000 * (PacketCounter - 1)), im.ImageData.Data, 0, size); 237 Array.Copy(m_asset.Data, 600 + (1000*(PacketCounter - 1)), im.ImageData.Data, 0, size);
238 req.RequestUser.OutPacket(im); 238 req.RequestUser.OutPacket(im);
239 PacketCounter++; 239 PacketCounter++;
240 } 240 }
241
242 } 241 }
243
244 } 242 }
245 243
246 public class AssetRequest 244 public class AssetRequest
@@ -258,6 +256,5 @@ namespace OpenSim.Region.Environment.Modules
258 PacketNumber = packetNumber; 256 PacketNumber = packetNumber;
259 } 257 }
260 } 258 }
261
262 } 259 }
263} 260} \ No newline at end of file