diff options
author | Adam Frisby | 2008-04-30 21:43:47 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-30 21:43:47 +0000 |
commit | be20f41637b6c06ce3ab16bc25851b6e43468e12 (patch) | |
tree | c41081329891f4c24de704fc760fb9012954ac9d /OpenSim/Region/Environment/Modules/Agent | |
parent | * Sometimes you know, you do something really stupid. (diff) | |
download | opensim-SC_OLD-be20f41637b6c06ce3ab16bc25851b6e43468e12.zip opensim-SC_OLD-be20f41637b6c06ce3ab16bc25851b6e43468e12.tar.gz opensim-SC_OLD-be20f41637b6c06ce3ab16bc25851b6e43468e12.tar.bz2 opensim-SC_OLD-be20f41637b6c06ce3ab16bc25851b6e43468e12.tar.xz |
* Cruft removal step #1. Cleaning Modules directory.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Agent')
8 files changed, 287 insertions, 249 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs index 47c1479..33e917a 100644 --- a/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs | |||
@@ -37,17 +37,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload | |||
37 | { | 37 | { |
38 | public class AssetDownloadModule : IRegionModule | 38 | public class AssetDownloadModule : IRegionModule |
39 | { | 39 | { |
40 | /// <summary> | ||
41 | /// Asset requests with data which are ready to be sent back to requesters. This includes textures. | ||
42 | /// </summary> | ||
43 | private List<AssetRequest> AssetRequests; | ||
44 | |||
40 | private Scene m_scene; | 45 | private Scene m_scene; |
41 | private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); | 46 | private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); |
47 | |||
42 | /// | 48 | /// |
43 | /// Assets requests (for each user) which are waiting for asset server data. This includes texture requests | 49 | /// Assets requests (for each user) which are waiting for asset server data. This includes texture requests |
44 | /// </summary> | 50 | /// </summary> |
45 | private Dictionary<LLUUID, Dictionary<LLUUID,AssetRequest>> RequestedAssets; | 51 | private Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>> RequestedAssets; |
46 | |||
47 | /// <summary> | ||
48 | /// Asset requests with data which are ready to be sent back to requesters. This includes textures. | ||
49 | /// </summary> | ||
50 | private List<AssetRequest> AssetRequests; | ||
51 | 52 | ||
52 | public AssetDownloadModule() | 53 | public AssetDownloadModule() |
53 | { | 54 | { |
@@ -55,6 +56,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload | |||
55 | AssetRequests = new List<AssetRequest>(); | 56 | AssetRequests = new List<AssetRequest>(); |
56 | } | 57 | } |
57 | 58 | ||
59 | #region IRegionModule Members | ||
60 | |||
58 | public void Initialise(Scene scene, IConfigSource config) | 61 | public void Initialise(Scene scene, IConfigSource config) |
59 | { | 62 | { |
60 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) | 63 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) |
@@ -92,6 +95,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload | |||
92 | get { return true; } | 95 | get { return true; } |
93 | } | 96 | } |
94 | 97 | ||
98 | #endregion | ||
99 | |||
95 | public void NewClient(IClientAPI client) | 100 | public void NewClient(IClientAPI client) |
96 | { | 101 | { |
97 | // client.OnRequestAsset += AddAssetRequest; | 102 | // client.OnRequestAsset += AddAssetRequest; |
@@ -301,33 +306,37 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload | |||
301 | { | 306 | { |
302 | // over max number of bytes so split up file | 307 | // over max number of bytes so split up file |
303 | long restData = data.LongLength - m_maxPacketSize; | 308 | long restData = data.LongLength - m_maxPacketSize; |
304 | int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize); | 309 | int restPackets = (int) ((restData + m_maxPacketSize - 1) / m_maxPacketSize); |
305 | numPackets += restPackets; | 310 | numPackets += restPackets; |
306 | } | 311 | } |
307 | 312 | ||
308 | return numPackets; | 313 | return numPackets; |
309 | } | 314 | } |
310 | 315 | ||
316 | #region Nested type: AssetRequest | ||
317 | |||
311 | public class AssetRequest | 318 | public class AssetRequest |
312 | { | 319 | { |
313 | public IClientAPI RequestUser; | ||
314 | public LLUUID RequestAssetID; | ||
315 | public AssetBase AssetInf; | 320 | public AssetBase AssetInf; |
316 | public AssetBase ImageInfo; | 321 | public byte AssetRequestSource = 2; |
317 | public LLUUID TransferRequestID; | ||
318 | public long DataPointer = 0; | 322 | public long DataPointer = 0; |
323 | public int DiscardLevel = -1; | ||
324 | public AssetBase ImageInfo; | ||
325 | public bool IsTextureRequest; | ||
319 | public int NumPackets = 0; | 326 | public int NumPackets = 0; |
320 | public int PacketCounter = 0; | 327 | public int PacketCounter = 0; |
321 | public bool IsTextureRequest; | ||
322 | public byte AssetRequestSource = 2; | ||
323 | public byte[] Params = null; | 328 | public byte[] Params = null; |
329 | public LLUUID RequestAssetID; | ||
330 | public IClientAPI RequestUser; | ||
331 | public LLUUID TransferRequestID; | ||
324 | //public bool AssetInCache; | 332 | //public bool AssetInCache; |
325 | //public int TimeRequested; | 333 | //public int TimeRequested; |
326 | public int DiscardLevel = -1; | ||
327 | 334 | ||
328 | public AssetRequest() | 335 | public AssetRequest() |
329 | { | 336 | { |
330 | } | 337 | } |
331 | } | 338 | } |
339 | |||
340 | #endregion | ||
332 | } | 341 | } |
333 | } \ No newline at end of file | 342 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs index 74bb247..8192be4 100644 --- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs | |||
@@ -42,12 +42,12 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
42 | { | 42 | { |
43 | //private static readonly log4net.ILog m_log | 43 | //private static readonly log4net.ILog m_log |
44 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 44 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | // Fields | 46 | // Fields |
47 | private bool m_dumpAssetsToFile; | ||
48 | public AgentAssetTransactionsManager Manager; | ||
47 | public LLUUID UserID; | 49 | public LLUUID UserID; |
48 | public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>(); | 50 | public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>(); |
49 | public AgentAssetTransactionsManager Manager; | ||
50 | private bool m_dumpAssetsToFile; | ||
51 | 51 | ||
52 | // Methods | 52 | // Methods |
53 | public AgentAssetTransactions(LLUUID agentID, AgentAssetTransactionsManager manager, bool dumpAssetsToFile) | 53 | public AgentAssetTransactions(LLUUID agentID, AgentAssetTransactionsManager manager, bool dumpAssetsToFile) |
@@ -67,7 +67,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
67 | { | 67 | { |
68 | XferUploaders.Add(transactionID, uploader); | 68 | XferUploaders.Add(transactionID, uploader); |
69 | } | 69 | } |
70 | 70 | ||
71 | return uploader; | 71 | return uploader; |
72 | } | 72 | } |
73 | return null; | 73 | return null; |
@@ -76,7 +76,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
76 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) | 76 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) |
77 | { | 77 | { |
78 | // AssetXferUploader uploaderFound = null; | 78 | // AssetXferUploader uploaderFound = null; |
79 | 79 | ||
80 | lock (XferUploaders) | 80 | lock (XferUploaders) |
81 | { | 81 | { |
82 | foreach (AssetXferUploader uploader in XferUploaders.Values) | 82 | foreach (AssetXferUploader uploader in XferUploaders.Values) |
@@ -86,7 +86,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
86 | uploader.HandleXferPacket(xferID, packetID, data); | 86 | uploader.HandleXferPacket(xferID, packetID, data); |
87 | break; | 87 | break; |
88 | } | 88 | } |
89 | } | 89 | } |
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
@@ -101,15 +101,15 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
101 | wearableType, nextOwnerMask); | 101 | wearableType, nextOwnerMask); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, | 105 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, |
106 | InventoryItemBase item) | 106 | InventoryItemBase item) |
107 | { | 107 | { |
108 | if (XferUploaders.ContainsKey(transactionID)) | 108 | if (XferUploaders.ContainsKey(transactionID)) |
109 | { | 109 | { |
110 | XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item); | 110 | XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | /// <summary> | 114 | /// <summary> |
115 | /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. | 115 | /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. |
@@ -122,40 +122,43 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
122 | { | 122 | { |
123 | AssetXferUploader uploader = XferUploaders[transactionID]; | 123 | AssetXferUploader uploader = XferUploaders[transactionID]; |
124 | AssetBase asset = uploader.GetAssetData(); | 124 | AssetBase asset = uploader.GetAssetData(); |
125 | 125 | ||
126 | lock (XferUploaders) | 126 | lock (XferUploaders) |
127 | { | 127 | { |
128 | XferUploaders.Remove(transactionID); | 128 | XferUploaders.Remove(transactionID); |
129 | } | 129 | } |
130 | 130 | ||
131 | return asset; | 131 | return asset; |
132 | } | 132 | } |
133 | 133 | ||
134 | return null; | 134 | return null; |
135 | } | 135 | } |
136 | 136 | ||
137 | // Nested Types | 137 | // Nested Types |
138 | |||
139 | #region Nested type: AssetXferUploader | ||
140 | |||
138 | public class AssetXferUploader | 141 | public class AssetXferUploader |
139 | { | 142 | { |
140 | // Fields | 143 | // Fields |
141 | public bool AddToInventory; | 144 | public bool AddToInventory; |
142 | public AssetBase Asset; | 145 | public AssetBase Asset; |
143 | public LLUUID InventFolder = LLUUID.Zero; | 146 | public LLUUID InventFolder = LLUUID.Zero; |
147 | private sbyte invType = 0; | ||
148 | private bool m_createItem = false; | ||
149 | private string m_description = String.Empty; | ||
150 | private bool m_dumpAssetToFile; | ||
151 | private bool m_finished = false; | ||
152 | private string m_name = String.Empty; | ||
153 | private bool m_storeLocal; | ||
154 | private AgentAssetTransactions m_userTransactions; | ||
155 | private uint nextPerm = 0; | ||
144 | private IClientAPI ourClient; | 156 | private IClientAPI ourClient; |
145 | public LLUUID TransactionID = LLUUID.Zero; | 157 | public LLUUID TransactionID = LLUUID.Zero; |
146 | public bool UploadComplete; | ||
147 | public ulong XferID; | ||
148 | private string m_name = String.Empty; | ||
149 | private string m_description = String.Empty; | ||
150 | private sbyte type = 0; | 158 | private sbyte type = 0; |
151 | private sbyte invType = 0; | 159 | public bool UploadComplete; |
152 | private byte wearableType = 0; | 160 | private byte wearableType = 0; |
153 | private uint nextPerm = 0; | 161 | public ulong XferID; |
154 | private bool m_finished = false; | ||
155 | private bool m_createItem = false; | ||
156 | private AgentAssetTransactions m_userTransactions; | ||
157 | private bool m_storeLocal; | ||
158 | private bool m_dumpAssetToFile; | ||
159 | 162 | ||
160 | public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) | 163 | public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) |
161 | { | 164 | { |
@@ -197,7 +200,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
197 | return true; | 200 | return true; |
198 | } | 201 | } |
199 | } | 202 | } |
200 | 203 | ||
201 | return false; | 204 | return false; |
202 | } | 205 | } |
203 | 206 | ||
@@ -233,7 +236,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
233 | { | 236 | { |
234 | RequestStartXfer(); | 237 | RequestStartXfer(); |
235 | } | 238 | } |
236 | 239 | ||
237 | return false; | 240 | return false; |
238 | } | 241 | } |
239 | 242 | ||
@@ -279,7 +282,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
279 | SaveAssetToFile(filename, Asset.Data); | 282 | SaveAssetToFile(filename, Asset.Data); |
280 | } | 283 | } |
281 | } | 284 | } |
282 | 285 | ||
283 | ///Left this in and commented in case there are unforseen issues | 286 | ///Left this in and commented in case there are unforseen issues |
284 | //private void SaveAssetToFile(string filename, byte[] data) | 287 | //private void SaveAssetToFile(string filename, byte[] data) |
285 | //{ | 288 | //{ |
@@ -327,28 +330,28 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
327 | } | 330 | } |
328 | } | 331 | } |
329 | } | 332 | } |
330 | 333 | ||
331 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, | 334 | public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, |
332 | InventoryItemBase item) | 335 | InventoryItemBase item) |
333 | { | 336 | { |
334 | if (TransactionID == transactionID) | 337 | if (TransactionID == transactionID) |
335 | { | 338 | { |
336 | CachedUserInfo userInfo = | 339 | CachedUserInfo userInfo = |
337 | m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( | 340 | m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( |
338 | remoteClient.AgentId); | 341 | remoteClient.AgentId); |
339 | 342 | ||
340 | if (userInfo != null) | 343 | if (userInfo != null) |
341 | { | 344 | { |
342 | LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId); | 345 | LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId); |
343 | 346 | ||
344 | AssetBase asset | 347 | AssetBase asset |
345 | = m_userTransactions.Manager.MyScene.CommsManager.AssetCache.GetAsset( | 348 | = m_userTransactions.Manager.MyScene.CommsManager.AssetCache.GetAsset( |
346 | assetID, (item.AssetType == (int) AssetType.Texture ? true : false)); | 349 | assetID, (item.AssetType == (int) AssetType.Texture ? true : false)); |
347 | 350 | ||
348 | if (asset == null) | 351 | if (asset == null) |
349 | { | 352 | { |
350 | asset = m_userTransactions.GetTransactionAsset(transactionID); | 353 | asset = m_userTransactions.GetTransactionAsset(transactionID); |
351 | } | 354 | } |
352 | 355 | ||
353 | if (asset != null && asset.FullID == assetID) | 356 | if (asset != null && asset.FullID == assetID) |
354 | { | 357 | { |
@@ -359,10 +362,10 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
359 | item.AssetID = asset.FullID; | 362 | item.AssetID = asset.FullID; |
360 | 363 | ||
361 | m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); | 364 | m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); |
362 | } | 365 | } |
363 | 366 | ||
364 | userInfo.UpdateItem(remoteClient.AgentId, item); | 367 | userInfo.UpdateItem(remoteClient.AgentId, item); |
365 | } | 368 | } |
366 | } | 369 | } |
367 | } | 370 | } |
368 | 371 | ||
@@ -387,7 +390,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
387 | item.BasePermissions = 2147483647; | 390 | item.BasePermissions = 2147483647; |
388 | item.CurrentPermissions = 2147483647; | 391 | item.CurrentPermissions = 2147483647; |
389 | item.NextPermissions = nextPerm; | 392 | item.NextPermissions = nextPerm; |
390 | item.Flags = (uint)wearableType; | 393 | item.Flags = (uint) wearableType; |
391 | 394 | ||
392 | userInfo.AddItem(ourClient.AgentId, item); | 395 | userInfo.AddItem(ourClient.AgentId, item); |
393 | ourClient.SendInventoryItemCreateUpdate(item); | 396 | ourClient.SendInventoryItemCreateUpdate(item); |
@@ -403,5 +406,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
403 | return null; | 406 | return null; |
404 | } | 407 | } |
405 | } | 408 | } |
409 | |||
410 | #endregion | ||
406 | } | 411 | } |
407 | } \ No newline at end of file | 412 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs index ef81625..b264c8a 100644 --- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs | |||
@@ -33,7 +33,6 @@ using log4net; | |||
33 | using Nini.Config; | 33 | using Nini.Config; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Region.Environment.Interfaces; | 35 | using OpenSim.Region.Environment.Interfaces; |
36 | using OpenSim.Region.Environment.Modules.Agent.AssetTransaction; | ||
37 | using OpenSim.Region.Environment.Scenes; | 36 | using OpenSim.Region.Environment.Scenes; |
38 | 37 | ||
39 | namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | 38 | namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction |
@@ -41,8 +40,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
41 | public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions | 40 | public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions |
42 | { | 41 | { |
43 | private readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); | 42 | private readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); |
44 | private Scene m_scene = null; | ||
45 | private bool m_dumpAssetsToFile = false; | 43 | private bool m_dumpAssetsToFile = false; |
44 | private Scene m_scene = null; | ||
46 | 45 | ||
47 | private AgentAssetTransactionsManager m_transactionManager; | 46 | private AgentAssetTransactionsManager m_transactionManager; |
48 | 47 | ||
@@ -51,6 +50,31 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
51 | // System.Console.WriteLine("creating AgentAssetTransactionModule"); | 50 | // System.Console.WriteLine("creating AgentAssetTransactionModule"); |
52 | } | 51 | } |
53 | 52 | ||
53 | #region IAgentAssetTransactions Members | ||
54 | |||
55 | public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, | ||
56 | uint callbackID, string description, string name, sbyte invType, | ||
57 | sbyte type, byte wearableType, uint nextOwnerMask) | ||
58 | { | ||
59 | m_transactionManager.HandleItemCreationFromTransaction(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, | ||
60 | wearableType, nextOwnerMask); | ||
61 | } | ||
62 | |||
63 | public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID, | ||
64 | InventoryItemBase item) | ||
65 | { | ||
66 | m_transactionManager.HandleItemUpdateFromTransaction(remoteClient, transactionID, item); | ||
67 | } | ||
68 | |||
69 | public void RemoveAgentAssetTransactions(LLUUID userID) | ||
70 | { | ||
71 | m_transactionManager.RemoveAgentAssetTransactions(userID); | ||
72 | } | ||
73 | |||
74 | #endregion | ||
75 | |||
76 | #region IRegionModule Members | ||
77 | |||
54 | public void Initialise(Scene scene, IConfigSource config) | 78 | public void Initialise(Scene scene, IConfigSource config) |
55 | { | 79 | { |
56 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) | 80 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) |
@@ -81,13 +105,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
81 | { | 105 | { |
82 | m_transactionManager = new AgentAssetTransactionsManager(m_scene, false); | 106 | m_transactionManager = new AgentAssetTransactionsManager(m_scene, false); |
83 | } | 107 | } |
84 | |||
85 | } | 108 | } |
86 | } | 109 | } |
87 | 110 | ||
88 | public void PostInitialise() | 111 | public void PostInitialise() |
89 | { | 112 | { |
90 | |||
91 | } | 113 | } |
92 | 114 | ||
93 | public void Close() | 115 | public void Close() |
@@ -104,29 +126,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
104 | get { return true; } | 126 | get { return true; } |
105 | } | 127 | } |
106 | 128 | ||
129 | #endregion | ||
130 | |||
107 | public void NewClient(IClientAPI client) | 131 | public void NewClient(IClientAPI client) |
108 | { | 132 | { |
109 | client.OnAssetUploadRequest += m_transactionManager.HandleUDPUploadRequest; | 133 | client.OnAssetUploadRequest += m_transactionManager.HandleUDPUploadRequest; |
110 | client.OnXferReceive += m_transactionManager.HandleXfer; | 134 | client.OnXferReceive += m_transactionManager.HandleXfer; |
111 | } | 135 | } |
112 | |||
113 | public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, | ||
114 | uint callbackID, string description, string name, sbyte invType, | ||
115 | sbyte type, byte wearableType, uint nextOwnerMask) | ||
116 | { | ||
117 | m_transactionManager.HandleItemCreationFromTransaction(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); | ||
118 | } | ||
119 | |||
120 | public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID, | ||
121 | InventoryItemBase item) | ||
122 | { | ||
123 | m_transactionManager.HandleItemUpdateFromTransaction(remoteClient, transactionID, item); | ||
124 | } | ||
125 | |||
126 | public void RemoveAgentAssetTransactions(LLUUID userID) | ||
127 | { | ||
128 | m_transactionManager.RemoveAgentAssetTransactions(userID); | ||
129 | } | ||
130 | } | 136 | } |
131 | 137 | ||
132 | public class AgentAssetTransactionsManager | 138 | public class AgentAssetTransactionsManager |
@@ -135,7 +141,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
135 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 141 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
136 | 142 | ||
137 | // Fields | 143 | // Fields |
138 | public Scene MyScene; | ||
139 | 144 | ||
140 | /// <summary> | 145 | /// <summary> |
141 | /// Each agent has its own singleton collection of transactions | 146 | /// Each agent has its own singleton collection of transactions |
@@ -148,6 +153,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
148 | /// </summary> | 153 | /// </summary> |
149 | private bool m_dumpAssetsToFile; | 154 | private bool m_dumpAssetsToFile; |
150 | 155 | ||
156 | public Scene MyScene; | ||
157 | |||
151 | public AgentAssetTransactionsManager(Scene scene, bool dumpAssetsToFile) | 158 | public AgentAssetTransactionsManager(Scene scene, bool dumpAssetsToFile) |
152 | { | 159 | { |
153 | MyScene = scene; | 160 | MyScene = scene; |
@@ -260,10 +267,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction | |||
260 | AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); | 267 | AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); |
261 | if (uploader != null) | 268 | if (uploader != null) |
262 | { | 269 | { |
263 | |||
264 | if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile)) | 270 | if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile)) |
265 | { | 271 | { |
266 | |||
267 | } | 272 | } |
268 | } | 273 | } |
269 | } | 274 | } |
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs index b8899d2..ae2df69 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs | |||
@@ -40,14 +40,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
40 | { | 40 | { |
41 | //private static readonly log4net.ILog m_log | 41 | //private static readonly log4net.ILog m_log |
42 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 42 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
43 | |||
44 | private Scene m_scene; | ||
45 | private List<Scene> m_scenes = new List<Scene>(); | ||
46 | 43 | ||
47 | /// <summary> | 44 | /// <summary> |
48 | /// There is one queue for all textures waiting to be sent, regardless of the requesting user. | 45 | /// There is one queue for all textures waiting to be sent, regardless of the requesting user. |
49 | /// </summary> | 46 | /// </summary> |
50 | private readonly BlockingQueue<ITextureSender> m_queueSenders | 47 | private readonly BlockingQueue<ITextureSender> m_queueSenders |
51 | = new BlockingQueue<ITextureSender>(); | 48 | = new BlockingQueue<ITextureSender>(); |
52 | 49 | ||
53 | /// <summary> | 50 | /// <summary> |
@@ -56,12 +53,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
56 | private readonly Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices = | 53 | private readonly Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices = |
57 | new Dictionary<LLUUID, UserTextureDownloadService>(); | 54 | new Dictionary<LLUUID, UserTextureDownloadService>(); |
58 | 55 | ||
56 | private Scene m_scene; | ||
57 | private List<Scene> m_scenes = new List<Scene>(); | ||
58 | |||
59 | private Thread m_thread; | 59 | private Thread m_thread; |
60 | 60 | ||
61 | public TextureDownloadModule() | 61 | public TextureDownloadModule() |
62 | { | 62 | { |
63 | } | 63 | } |
64 | 64 | ||
65 | #region IRegionModule Members | ||
66 | |||
65 | public void Initialise(Scene scene, IConfigSource config) | 67 | public void Initialise(Scene scene, IConfigSource config) |
66 | { | 68 | { |
67 | if (m_scene == null) | 69 | if (m_scene == null) |
@@ -83,6 +85,26 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
83 | } | 85 | } |
84 | } | 86 | } |
85 | 87 | ||
88 | public void PostInitialise() | ||
89 | { | ||
90 | } | ||
91 | |||
92 | public void Close() | ||
93 | { | ||
94 | } | ||
95 | |||
96 | public string Name | ||
97 | { | ||
98 | get { return "TextureDownloadModule"; } | ||
99 | } | ||
100 | |||
101 | public bool IsSharedModule | ||
102 | { | ||
103 | get { return false; } | ||
104 | } | ||
105 | |||
106 | #endregion | ||
107 | |||
86 | /// <summary> | 108 | /// <summary> |
87 | /// Cleanup the texture service related objects for the removed presence. | 109 | /// Cleanup the texture service related objects for the removed presence. |
88 | /// </summary> | 110 | /// </summary> |
@@ -102,24 +124,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
102 | } | 124 | } |
103 | } | 125 | } |
104 | 126 | ||
105 | public void PostInitialise() | ||
106 | { | ||
107 | } | ||
108 | |||
109 | public void Close() | ||
110 | { | ||
111 | } | ||
112 | |||
113 | public string Name | ||
114 | { | ||
115 | get { return "TextureDownloadModule"; } | ||
116 | } | ||
117 | |||
118 | public bool IsSharedModule | ||
119 | { | ||
120 | get { return false; } | ||
121 | } | ||
122 | |||
123 | public void NewClient(IClientAPI client) | 127 | public void NewClient(IClientAPI client) |
124 | { | 128 | { |
125 | client.OnRequestTexture += TextureRequest; | 129 | client.OnRequestTexture += TextureRequest; |
@@ -143,7 +147,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
143 | 147 | ||
144 | textureService = new UserTextureDownloadService(client, m_scene, m_queueSenders); | 148 | textureService = new UserTextureDownloadService(client, m_scene, m_queueSenders); |
145 | m_userTextureServices.Add(client.AgentId, textureService); | 149 | m_userTextureServices.Add(client.AgentId, textureService); |
146 | 150 | ||
147 | return true; | 151 | return true; |
148 | } | 152 | } |
149 | } | 153 | } |
@@ -157,11 +161,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
157 | { | 161 | { |
158 | IClientAPI client = (IClientAPI) sender; | 162 | IClientAPI client = (IClientAPI) sender; |
159 | UserTextureDownloadService textureService; | 163 | UserTextureDownloadService textureService; |
160 | 164 | ||
161 | if (TryGetUserTextureService(client, out textureService)) | 165 | if (TryGetUserTextureService(client, out textureService)) |
162 | { | 166 | { |
163 | textureService.HandleTextureRequest(e); | 167 | textureService.HandleTextureRequest(e); |
164 | } | 168 | } |
165 | } | 169 | } |
166 | 170 | ||
167 | /// <summary> | 171 | /// <summary> |
@@ -170,11 +174,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
170 | public void ProcessTextureSenders() | 174 | public void ProcessTextureSenders() |
171 | { | 175 | { |
172 | ITextureSender sender = null; | 176 | ITextureSender sender = null; |
173 | 177 | ||
174 | while (true) | 178 | while (true) |
175 | { | 179 | { |
176 | sender = m_queueSenders.Dequeue(); | 180 | sender = m_queueSenders.Dequeue(); |
177 | 181 | ||
178 | if (sender.Cancel) | 182 | if (sender.Cancel) |
179 | { | 183 | { |
180 | TextureSent(sender); | 184 | TextureSent(sender); |
@@ -193,10 +197,10 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
193 | m_queueSenders.Enqueue(sender); | 197 | m_queueSenders.Enqueue(sender); |
194 | } | 198 | } |
195 | } | 199 | } |
196 | 200 | ||
197 | // Make sure that any sender we currently have can get garbage collected | 201 | // Make sure that any sender we currently have can get garbage collected |
198 | sender = null; | 202 | sender = null; |
199 | 203 | ||
200 | //m_log.InfoFormat("[TEXTURE DOWNLOAD] Texture sender queue size: {0}", m_queueSenders.Count()); | 204 | //m_log.InfoFormat("[TEXTURE DOWNLOAD] Texture sender queue size: {0}", m_queueSenders.Count()); |
201 | } | 205 | } |
202 | } | 206 | } |
@@ -207,9 +211,9 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
207 | /// <param name="sender"></param> | 211 | /// <param name="sender"></param> |
208 | private void TextureSent(ITextureSender sender) | 212 | private void TextureSent(ITextureSender sender) |
209 | { | 213 | { |
210 | sender.Sending = false; | 214 | sender.Sending = false; |
211 | //m_log.DebugFormat("[TEXTURE DOWNLOAD]: Removing download stat for {0}", sender.assetID); | 215 | //m_log.DebugFormat("[TEXTURE DOWNLOAD]: Removing download stat for {0}", sender.assetID); |
212 | m_scene.AddPendingDownloads(-1); | 216 | m_scene.AddPendingDownloads(-1); |
213 | } | 217 | } |
214 | } | 218 | } |
215 | } \ No newline at end of file | 219 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs index 6f11f73..b181d20 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs | |||
@@ -39,55 +39,60 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
39 | { | 39 | { |
40 | //private static readonly log4net.ILog m_log | 40 | //private static readonly log4net.ILog m_log |
41 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 41 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
42 | 42 | ||
43 | private LLUUID m_textureId; | 43 | private bool m_cancel = false; |
44 | private IClientAPI m_client; | 44 | private IClientAPI m_client; |
45 | 45 | ||
46 | // See ITextureSender | 46 | // See ITextureSender |
47 | public bool Sending | 47 | |
48 | { | 48 | private bool m_sending = false; |
49 | get { return false; } | 49 | private LLUUID m_textureId; |
50 | set { m_sending = value; } | ||
51 | } | ||
52 | |||
53 | private bool m_sending = false; | ||
54 | 50 | ||
55 | // See ITextureSender | 51 | // See ITextureSender |
56 | public bool Cancel | 52 | |
57 | { | ||
58 | get { return false; } | ||
59 | set { m_cancel = value; } | ||
60 | } | ||
61 | |||
62 | private bool m_cancel = false; | ||
63 | |||
64 | public TextureNotFoundSender(IClientAPI client, LLUUID textureID) | 53 | public TextureNotFoundSender(IClientAPI client, LLUUID textureID) |
65 | { | 54 | { |
66 | m_client = client; | 55 | m_client = client; |
67 | m_textureId = textureID; | 56 | m_textureId = textureID; |
68 | } | 57 | } |
69 | 58 | ||
59 | #region ITextureSender Members | ||
60 | |||
61 | public bool Sending | ||
62 | { | ||
63 | get { return false; } | ||
64 | set { m_sending = value; } | ||
65 | } | ||
66 | |||
67 | public bool Cancel | ||
68 | { | ||
69 | get { return false; } | ||
70 | set { m_cancel = value; } | ||
71 | } | ||
72 | |||
70 | // See ITextureSender | 73 | // See ITextureSender |
71 | public void UpdateRequest(int discardLevel, uint packetNumber) | 74 | public void UpdateRequest(int discardLevel, uint packetNumber) |
72 | { | 75 | { |
73 | // Not need to implement since priority changes don't affect this operation | 76 | // Not need to implement since priority changes don't affect this operation |
74 | } | 77 | } |
75 | 78 | ||
76 | // See ITextureSender | 79 | // See ITextureSender |
77 | public bool SendTexturePacket() | 80 | public bool SendTexturePacket() |
78 | { | 81 | { |
79 | //m_log.InfoFormat( | 82 | //m_log.InfoFormat( |
80 | // "[TEXTURE NOT FOUND SENDER]: Informing the client that texture {0} cannot be found", | 83 | // "[TEXTURE NOT FOUND SENDER]: Informing the client that texture {0} cannot be found", |
81 | // m_textureId); | 84 | // m_textureId); |
82 | 85 | ||
83 | ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket(); | 86 | ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket(); |
84 | notFound.ImageID.ID = m_textureId; | 87 | notFound.ImageID.ID = m_textureId; |
85 | 88 | ||
86 | // XXX Temporarily disabling as this appears to be causing client crashes on at least | 89 | // XXX Temporarily disabling as this appears to be causing client crashes on at least |
87 | // 1.19.0(5) of the Linden Second Life client. | 90 | // 1.19.0(5) of the Linden Second Life client. |
88 | // m_client.OutPacket(notFound, ThrottleOutPacketType.Texture); | 91 | // m_client.OutPacket(notFound, ThrottleOutPacketType.Texture); |
89 | 92 | ||
90 | return true; | 93 | return true; |
91 | } | 94 | } |
95 | |||
96 | #endregion | ||
92 | } | 97 | } |
93 | } \ No newline at end of file | 98 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs index 08a22d6..4f63fd0 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs | |||
@@ -32,8 +32,6 @@ using log4net; | |||
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Communications.Limit; | 33 | using OpenSim.Framework.Communications.Limit; |
34 | using OpenSim.Region.Environment.Interfaces; | 34 | using OpenSim.Region.Environment.Interfaces; |
35 | using OpenSim.Region.Environment.Modules.Agent.TextureDownload; | ||
36 | using OpenSim.Region.Environment.Modules.Agent.TextureSender; | ||
37 | using OpenSim.Region.Environment.Scenes; | 35 | using OpenSim.Region.Environment.Scenes; |
38 | 36 | ||
39 | namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | 37 | namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload |
@@ -45,7 +43,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
45 | /// </summary> | 43 | /// </summary> |
46 | public class UserTextureDownloadService | 44 | public class UserTextureDownloadService |
47 | { | 45 | { |
48 | private static readonly ILog m_log | 46 | private static readonly ILog m_log |
49 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 48 | ||
51 | /// <summary> | 49 | /// <summary> |
@@ -56,35 +54,34 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
56 | /// sophisticated way. | 54 | /// sophisticated way. |
57 | /// </summary> | 55 | /// </summary> |
58 | private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 5; | 56 | private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 5; |
59 | 57 | ||
60 | /// <summary> | ||
61 | /// We're going to limit requests for the same missing texture. | ||
62 | /// XXX This is really a temporary solution to deal with the situation where a client continually requests | ||
63 | /// the same missing textures | ||
64 | /// </summary> | ||
65 | private readonly IRequestLimitStrategy<LLUUID> missingTextureLimitStrategy | ||
66 | = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS); | ||
67 | |||
68 | /// <summary> | 58 | /// <summary> |
69 | /// XXX Also going to limit requests for found textures. | 59 | /// XXX Also going to limit requests for found textures. |
70 | /// </summary> | 60 | /// </summary> |
71 | private readonly IRequestLimitStrategy<LLUUID> foundTextureLimitStrategy | 61 | private readonly IRequestLimitStrategy<LLUUID> foundTextureLimitStrategy |
72 | = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS); | 62 | = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS); |
73 | 63 | ||
74 | /// <summary> | 64 | private readonly IClientAPI m_client; |
75 | /// Holds texture senders before they have received the appropriate texture from the asset cache. | 65 | private readonly Scene m_scene; |
76 | /// </summary> | 66 | |
77 | private readonly Dictionary<LLUUID, TextureSender.TextureSender> m_textureSenders = new Dictionary<LLUUID, TextureSender.TextureSender>(); | ||
78 | |||
79 | /// <summary> | 67 | /// <summary> |
80 | /// Texture Senders are placed in this queue once they have received their texture from the asset | 68 | /// Texture Senders are placed in this queue once they have received their texture from the asset |
81 | /// cache. Another module actually invokes the send. | 69 | /// cache. Another module actually invokes the send. |
82 | /// </summary> | 70 | /// </summary> |
83 | private readonly BlockingQueue<ITextureSender> m_sharedSendersQueue; | 71 | private readonly BlockingQueue<ITextureSender> m_sharedSendersQueue; |
84 | 72 | ||
85 | private readonly Scene m_scene; | 73 | /// <summary> |
86 | 74 | /// Holds texture senders before they have received the appropriate texture from the asset cache. | |
87 | private readonly IClientAPI m_client; | 75 | /// </summary> |
76 | private readonly Dictionary<LLUUID, TextureSender.TextureSender> m_textureSenders = new Dictionary<LLUUID, TextureSender.TextureSender>(); | ||
77 | |||
78 | /// <summary> | ||
79 | /// We're going to limit requests for the same missing texture. | ||
80 | /// XXX This is really a temporary solution to deal with the situation where a client continually requests | ||
81 | /// the same missing textures | ||
82 | /// </summary> | ||
83 | private readonly IRequestLimitStrategy<LLUUID> missingTextureLimitStrategy | ||
84 | = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS); | ||
88 | 85 | ||
89 | public UserTextureDownloadService( | 86 | public UserTextureDownloadService( |
90 | IClientAPI client, Scene scene, BlockingQueue<ITextureSender> sharedQueue) | 87 | IClientAPI client, Scene scene, BlockingQueue<ITextureSender> sharedQueue) |
@@ -112,19 +109,19 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
112 | { | 109 | { |
113 | // If we've received new non UUID information for this request and it hasn't dispatched | 110 | // If we've received new non UUID information for this request and it hasn't dispatched |
114 | // yet, then update the request accordingly. | 111 | // yet, then update the request accordingly. |
115 | textureSender.UpdateRequest(e.DiscardLevel, e.PacketNumber); | 112 | textureSender.UpdateRequest(e.DiscardLevel, e.PacketNumber); |
116 | } | 113 | } |
117 | else | 114 | else |
118 | { | 115 | { |
119 | if (!foundTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) | 116 | if (!foundTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) |
120 | { | 117 | { |
121 | // m_log.DebugFormat( | 118 | // m_log.DebugFormat( |
122 | // "[USER TEXTURE DOWNLOAD SERVICE]: Refusing request for {0} from client {1}", | 119 | // "[USER TEXTURE DOWNLOAD SERVICE]: Refusing request for {0} from client {1}", |
123 | // e.RequestedAssetID, m_client.AgentId); | 120 | // e.RequestedAssetID, m_client.AgentId); |
124 | 121 | ||
125 | return; | 122 | return; |
126 | } | 123 | } |
127 | else if (!missingTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) | 124 | else if (!missingTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) |
128 | { | 125 | { |
129 | if (missingTextureLimitStrategy.IsFirstRefusal(e.RequestedAssetID)) | 126 | if (missingTextureLimitStrategy.IsFirstRefusal(e.RequestedAssetID)) |
130 | { | 127 | { |
@@ -135,17 +132,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
135 | // m_log.DebugFormat( | 132 | // m_log.DebugFormat( |
136 | // "[USER TEXTURE DOWNLOAD SERVICE]: Dropping requests for notified missing texture {0} for client {1} since we have received more than {2} requests", | 133 | // "[USER TEXTURE DOWNLOAD SERVICE]: Dropping requests for notified missing texture {0} for client {1} since we have received more than {2} requests", |
137 | // e.RequestedAssetID, m_client.AgentId, MAX_ALLOWED_TEXTURE_REQUESTS); | 134 | // e.RequestedAssetID, m_client.AgentId, MAX_ALLOWED_TEXTURE_REQUESTS); |
138 | } | 135 | } |
139 | 136 | ||
140 | return; | 137 | return; |
141 | } | 138 | } |
142 | 139 | ||
143 | m_scene.AddPendingDownloads(1); | 140 | m_scene.AddPendingDownloads(1); |
144 | 141 | ||
145 | TextureSender.TextureSender requestHandler = new TextureSender.TextureSender(m_client, e.DiscardLevel, e.PacketNumber); | 142 | TextureSender.TextureSender requestHandler = new TextureSender.TextureSender(m_client, e.DiscardLevel, e.PacketNumber); |
146 | m_textureSenders.Add(e.RequestedAssetID, requestHandler); | 143 | m_textureSenders.Add(e.RequestedAssetID, requestHandler); |
147 | 144 | ||
148 | m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback, true); | 145 | m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback, true); |
149 | } | 146 | } |
150 | } | 147 | } |
151 | } | 148 | } |
@@ -170,7 +167,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
170 | public void TextureCallback(LLUUID textureID, AssetBase texture) | 167 | public void TextureCallback(LLUUID textureID, AssetBase texture) |
171 | { | 168 | { |
172 | //m_log.DebugFormat("[USER TEXTURE DOWNLOAD SERVICE]: Calling TextureCallback with {0}, texture == null is {1}", textureID, (texture == null ? true : false)); | 169 | //m_log.DebugFormat("[USER TEXTURE DOWNLOAD SERVICE]: Calling TextureCallback with {0}, texture == null is {1}", textureID, (texture == null ? true : false)); |
173 | 170 | ||
174 | lock (m_textureSenders) | 171 | lock (m_textureSenders) |
175 | { | 172 | { |
176 | TextureSender.TextureSender textureSender; | 173 | TextureSender.TextureSender textureSender; |
@@ -181,18 +178,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
181 | // this on to the TextureSender it will blow up, so just discard for now. | 178 | // this on to the TextureSender it will blow up, so just discard for now. |
182 | // Needs investigation. | 179 | // Needs investigation. |
183 | if (texture == null || texture.Data == null) | 180 | if (texture == null || texture.Data == null) |
184 | { | 181 | { |
185 | if (!missingTextureLimitStrategy.IsMonitoringRequests(textureID)) | 182 | if (!missingTextureLimitStrategy.IsMonitoringRequests(textureID)) |
186 | { | 183 | { |
187 | missingTextureLimitStrategy.MonitorRequests(textureID); | 184 | missingTextureLimitStrategy.MonitorRequests(textureID); |
188 | 185 | ||
189 | m_log.DebugFormat( | 186 | m_log.DebugFormat( |
190 | "[USER TEXTURE DOWNLOAD SERVICE]: Queueing first TextureNotFoundSender for {0}, client {1}", | 187 | "[USER TEXTURE DOWNLOAD SERVICE]: Queueing first TextureNotFoundSender for {0}, client {1}", |
191 | textureID, m_client.AgentId); | 188 | textureID, m_client.AgentId); |
192 | } | 189 | } |
193 | 190 | ||
194 | ITextureSender textureNotFoundSender = new TextureNotFoundSender(m_client, textureID); | 191 | ITextureSender textureNotFoundSender = new TextureNotFoundSender(m_client, textureID); |
195 | EnqueueTextureSender(textureNotFoundSender); | 192 | EnqueueTextureSender(textureNotFoundSender); |
196 | } | 193 | } |
197 | else | 194 | else |
198 | { | 195 | { |
@@ -200,13 +197,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
200 | { | 197 | { |
201 | textureSender.TextureReceived(texture); | 198 | textureSender.TextureReceived(texture); |
202 | EnqueueTextureSender(textureSender); | 199 | EnqueueTextureSender(textureSender); |
203 | 200 | ||
204 | foundTextureLimitStrategy.MonitorRequests(textureID); | 201 | foundTextureLimitStrategy.MonitorRequests(textureID); |
205 | } | 202 | } |
206 | } | 203 | } |
207 | 204 | ||
208 | //m_log.InfoFormat("[TEXTURE SENDER] Removing texture sender with uuid {0}", textureID); | 205 | //m_log.InfoFormat("[TEXTURE SENDER] Removing texture sender with uuid {0}", textureID); |
209 | m_textureSenders.Remove(textureID); | 206 | m_textureSenders.Remove(textureID); |
210 | //m_log.InfoFormat("[TEXTURE SENDER] Current texture senders in dictionary: {0}", m_textureSenders.Count); | 207 | //m_log.InfoFormat("[TEXTURE SENDER] Current texture senders in dictionary: {0}", m_textureSenders.Count); |
211 | } | 208 | } |
212 | else | 209 | else |
@@ -240,7 +237,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload | |||
240 | { | 237 | { |
241 | lock (m_textureSenders) | 238 | lock (m_textureSenders) |
242 | { | 239 | { |
243 | foreach( TextureSender.TextureSender textureSender in m_textureSenders.Values ) | 240 | foreach (TextureSender.TextureSender textureSender in m_textureSenders.Values) |
244 | { | 241 | { |
245 | textureSender.Cancel = true; | 242 | textureSender.Cancel = true; |
246 | } | 243 | } |
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs index 37b0652..b6f7095 100644 --- a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs +++ b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs | |||
@@ -40,56 +40,43 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender | |||
40 | /// </summary> | 40 | /// </summary> |
41 | public class TextureSender : ITextureSender | 41 | public class TextureSender : ITextureSender |
42 | { | 42 | { |
43 | private static readonly ILog m_log | 43 | private static readonly ILog m_log |
44 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | /// <summary> | 46 | /// <summary> |
47 | /// Records the number of times texture send has been called. | 47 | /// Records the number of times texture send has been called. |
48 | /// </summary> | 48 | /// </summary> |
49 | public int counter = 0; | 49 | public int counter = 0; |
50 | 50 | ||
51 | public bool ImageLoaded = false; | ||
52 | |||
51 | /// <summary> | 53 | /// <summary> |
52 | /// Holds the texture asset to send. | 54 | /// Holds the texture asset to send. |
53 | /// </summary> | 55 | /// </summary> |
54 | private AssetBase m_asset; | 56 | private AssetBase m_asset; |
55 | 57 | ||
56 | //public LLUUID assetID { get { return m_asset.FullID; } } | 58 | //public LLUUID assetID { get { return m_asset.FullID; } } |
57 | 59 | ||
60 | private bool m_cancel = false; | ||
61 | |||
62 | // See ITextureSender | ||
63 | |||
64 | private bool m_sending = false; | ||
65 | |||
58 | /// <summary> | 66 | /// <summary> |
59 | /// This is actually the number of extra packets required to send the texture data! We always assume | 67 | /// This is actually the number of extra packets required to send the texture data! We always assume |
60 | /// at least one is required. | 68 | /// at least one is required. |
61 | /// </summary> | 69 | /// </summary> |
62 | private int NumPackets = 0; | 70 | private int NumPackets = 0; |
63 | 71 | ||
64 | /// <summary> | 72 | /// <summary> |
65 | /// Holds the packet number to send next. In this case, each packet is 1000 bytes long and starts | 73 | /// Holds the packet number to send next. In this case, each packet is 1000 bytes long and starts |
66 | /// at the 600th byte (0th indexed). | 74 | /// at the 600th byte (0th indexed). |
67 | /// </summary> | 75 | /// </summary> |
68 | private int PacketCounter = 0; | 76 | private int PacketCounter = 0; |
69 | |||
70 | // See ITextureSender | ||
71 | public bool Cancel | ||
72 | { | ||
73 | get { return false; } | ||
74 | set { m_cancel = value; } | ||
75 | } | ||
76 | |||
77 | private bool m_cancel = false; | ||
78 | |||
79 | // See ITextureSender | ||
80 | public bool Sending | ||
81 | { | ||
82 | get { return false; } | ||
83 | set { m_sending = value; } | ||
84 | } | ||
85 | |||
86 | private bool m_sending = false; | ||
87 | |||
88 | public bool ImageLoaded = false; | ||
89 | |||
90 | private IClientAPI RequestUser; | ||
91 | 77 | ||
92 | private int RequestedDiscardLevel = -1; | 78 | private int RequestedDiscardLevel = -1; |
79 | private IClientAPI RequestUser; | ||
93 | private uint StartPacketNumber = 0; | 80 | private uint StartPacketNumber = 0; |
94 | 81 | ||
95 | public TextureSender(IClientAPI client, int discardLevel, uint packetNumber) | 82 | public TextureSender(IClientAPI client, int discardLevel, uint packetNumber) |
@@ -99,18 +86,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender | |||
99 | StartPacketNumber = packetNumber; | 86 | StartPacketNumber = packetNumber; |
100 | } | 87 | } |
101 | 88 | ||
102 | /// <summary> | 89 | #region ITextureSender Members |
103 | /// Load up the texture data to send. | 90 | |
104 | /// </summary> | 91 | public bool Cancel |
105 | /// <param name="asset"> | ||
106 | /// A <see cref="AssetBase"/> | ||
107 | /// </param> | ||
108 | public void TextureReceived(AssetBase asset) | ||
109 | { | 92 | { |
110 | m_asset = asset; | 93 | get { return false; } |
111 | NumPackets = CalculateNumPackets(asset.Data.Length); | 94 | set { m_cancel = value; } |
112 | PacketCounter = (int) StartPacketNumber; | 95 | } |
113 | ImageLoaded = true; | 96 | |
97 | public bool Sending | ||
98 | { | ||
99 | get { return false; } | ||
100 | set { m_sending = value; } | ||
114 | } | 101 | } |
115 | 102 | ||
116 | // See ITextureSender | 103 | // See ITextureSender |
@@ -125,17 +112,33 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender | |||
125 | public bool SendTexturePacket() | 112 | public bool SendTexturePacket() |
126 | { | 113 | { |
127 | //m_log.DebugFormat("[TEXTURE SENDER]: Sending packet for {0}", m_asset.FullID); | 114 | //m_log.DebugFormat("[TEXTURE SENDER]: Sending packet for {0}", m_asset.FullID); |
128 | 115 | ||
129 | SendPacket(); | 116 | SendPacket(); |
130 | counter++; | 117 | counter++; |
131 | if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || | 118 | if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || |
132 | ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets/(RequestedDiscardLevel + 1))))) | 119 | ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets / (RequestedDiscardLevel + 1))))) |
133 | { | 120 | { |
134 | return true; | 121 | return true; |
135 | } | 122 | } |
136 | return false; | 123 | return false; |
137 | } | 124 | } |
138 | 125 | ||
126 | #endregion | ||
127 | |||
128 | /// <summary> | ||
129 | /// Load up the texture data to send. | ||
130 | /// </summary> | ||
131 | /// <param name="asset"> | ||
132 | /// A <see cref="AssetBase"/> | ||
133 | /// </param> | ||
134 | public void TextureReceived(AssetBase asset) | ||
135 | { | ||
136 | m_asset = asset; | ||
137 | NumPackets = CalculateNumPackets(asset.Data.Length); | ||
138 | PacketCounter = (int) StartPacketNumber; | ||
139 | ImageLoaded = true; | ||
140 | } | ||
141 | |||
139 | /// <summary> | 142 | /// <summary> |
140 | /// Sends a texture packet to the client. | 143 | /// Sends a texture packet to the client. |
141 | /// </summary> | 144 | /// </summary> |
@@ -177,17 +180,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender | |||
177 | im.Header.Reliable = false; | 180 | im.Header.Reliable = false; |
178 | im.ImageID.Packet = (ushort) (PacketCounter); | 181 | im.ImageID.Packet = (ushort) (PacketCounter); |
179 | im.ImageID.ID = m_asset.FullID; | 182 | im.ImageID.ID = m_asset.FullID; |
180 | int size = m_asset.Data.Length - 600 - (1000*(PacketCounter - 1)); | 183 | int size = m_asset.Data.Length - 600 - (1000 * (PacketCounter - 1)); |
181 | if (size > 1000) size = 1000; | 184 | if (size > 1000) size = 1000; |
182 | im.ImageData.Data = new byte[size]; | 185 | im.ImageData.Data = new byte[size]; |
183 | try | 186 | try |
184 | { | 187 | { |
185 | Array.Copy(m_asset.Data, 600 + (1000*(PacketCounter - 1)), im.ImageData.Data, 0, size); | 188 | Array.Copy(m_asset.Data, 600 + (1000 * (PacketCounter - 1)), im.ImageData.Data, 0, size); |
186 | } | 189 | } |
187 | catch (ArgumentOutOfRangeException) | 190 | catch (ArgumentOutOfRangeException) |
188 | { | 191 | { |
189 | m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" + | 192 | m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" + |
190 | m_asset.FullID.ToString() ); | 193 | m_asset.FullID.ToString()); |
191 | return; | 194 | return; |
192 | } | 195 | } |
193 | RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); | 196 | RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); |
@@ -210,7 +213,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender | |||
210 | { | 213 | { |
211 | //over 600 bytes so split up file | 214 | //over 600 bytes so split up file |
212 | int restData = (length - 600); | 215 | int restData = (length - 600); |
213 | int restPackets = ((restData + 999)/1000); | 216 | int restPackets = ((restData + 999) / 1000); |
214 | numPackets = restPackets; | 217 | numPackets = restPackets; |
215 | } | 218 | } |
216 | 219 | ||
diff --git a/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs b/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs index b609f93..e35b6f5 100644 --- a/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs | |||
@@ -37,15 +37,16 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer | |||
37 | { | 37 | { |
38 | public class XferModule : IRegionModule, IXfer | 38 | public class XferModule : IRegionModule, IXfer |
39 | { | 39 | { |
40 | private Scene m_scene; | ||
40 | public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>(); | 41 | public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>(); |
41 | public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); | 42 | public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); |
42 | 43 | ||
43 | private Scene m_scene; | ||
44 | |||
45 | public XferModule() | 44 | public XferModule() |
46 | { | 45 | { |
47 | } | 46 | } |
48 | 47 | ||
48 | #region IRegionModule Members | ||
49 | |||
49 | public void Initialise(Scene scene, IConfigSource config) | 50 | public void Initialise(Scene scene, IConfigSource config) |
50 | { | 51 | { |
51 | m_scene = scene; | 52 | m_scene = scene; |
@@ -72,6 +73,28 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer | |||
72 | get { return false; } | 73 | get { return false; } |
73 | } | 74 | } |
74 | 75 | ||
76 | #endregion | ||
77 | |||
78 | #region IXfer Members | ||
79 | |||
80 | public bool AddNewFile(string fileName, byte[] data) | ||
81 | { | ||
82 | lock (NewFiles) | ||
83 | { | ||
84 | if (NewFiles.ContainsKey(fileName)) | ||
85 | { | ||
86 | NewFiles[fileName] = data; | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | NewFiles.Add(fileName, data); | ||
91 | } | ||
92 | } | ||
93 | return true; | ||
94 | } | ||
95 | |||
96 | #endregion | ||
97 | |||
75 | public void NewClient(IClientAPI client) | 98 | public void NewClient(IClientAPI client) |
76 | { | 99 | { |
77 | client.OnRequestXfer += RequestXfer; | 100 | client.OnRequestXfer += RequestXfer; |
@@ -96,7 +119,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer | |||
96 | XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); | 119 | XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); |
97 | Transfers.Add(xferID, transaction); | 120 | Transfers.Add(xferID, transaction); |
98 | NewFiles.Remove(fileName); | 121 | NewFiles.Remove(fileName); |
99 | 122 | ||
100 | if (transaction.StartSend()) | 123 | if (transaction.StartSend()) |
101 | { | 124 | { |
102 | Transfers.Remove(xferID); | 125 | Transfers.Remove(xferID); |
@@ -119,33 +142,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer | |||
119 | } | 142 | } |
120 | } | 143 | } |
121 | 144 | ||
122 | public bool AddNewFile(string fileName, byte[] data) | 145 | #region Nested type: XferDownLoad |
123 | { | ||
124 | lock (NewFiles) | ||
125 | { | ||
126 | if (NewFiles.ContainsKey(fileName)) | ||
127 | { | ||
128 | NewFiles[fileName] = data; | ||
129 | } | ||
130 | else | ||
131 | { | ||
132 | NewFiles.Add(fileName, data); | ||
133 | } | ||
134 | } | ||
135 | return true; | ||
136 | } | ||
137 | |||
138 | 146 | ||
139 | public class XferDownLoad | 147 | public class XferDownLoad |
140 | { | 148 | { |
149 | public IClientAPI Client; | ||
150 | private bool complete; | ||
141 | public byte[] Data = new byte[0]; | 151 | public byte[] Data = new byte[0]; |
142 | public string FileName = String.Empty; | ||
143 | public ulong XferID = 0; | ||
144 | public int DataPointer = 0; | 152 | public int DataPointer = 0; |
153 | public string FileName = String.Empty; | ||
145 | public uint Packet = 0; | 154 | public uint Packet = 0; |
146 | public IClientAPI Client; | ||
147 | public uint Serial = 1; | 155 | public uint Serial = 1; |
148 | private bool complete; | 156 | public ulong XferID = 0; |
149 | 157 | ||
150 | public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) | 158 | public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) |
151 | { | 159 | { |
@@ -172,7 +180,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer | |||
172 | Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); | 180 | Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); |
173 | Array.Copy(Data, 0, transferData, 4, Data.Length); | 181 | Array.Copy(Data, 0, transferData, 4, Data.Length); |
174 | Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); | 182 | Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); |
175 | 183 | ||
176 | complete = true; | 184 | complete = true; |
177 | } | 185 | } |
178 | else | 186 | else |
@@ -182,10 +190,10 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer | |||
182 | Array.Copy(Data, 0, transferData, 4, 1000); | 190 | Array.Copy(Data, 0, transferData, 4, 1000); |
183 | Client.SendXferPacket(XferID, 0, transferData); | 191 | Client.SendXferPacket(XferID, 0, transferData); |
184 | Packet++; | 192 | Packet++; |
185 | DataPointer = 1000; | 193 | DataPointer = 1000; |
186 | } | 194 | } |
187 | 195 | ||
188 | return complete; | 196 | return complete; |
189 | } | 197 | } |
190 | 198 | ||
191 | /// <summary> | 199 | /// <summary> |
@@ -213,13 +221,15 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer | |||
213 | Client.SendXferPacket(XferID, endPacket, transferData); | 221 | Client.SendXferPacket(XferID, endPacket, transferData); |
214 | Packet++; | 222 | Packet++; |
215 | DataPointer += (Data.Length - DataPointer); | 223 | DataPointer += (Data.Length - DataPointer); |
216 | 224 | ||
217 | complete = true; | 225 | complete = true; |
218 | } | 226 | } |
219 | } | 227 | } |
220 | 228 | ||
221 | return complete; | 229 | return complete; |
222 | } | 230 | } |
223 | } | 231 | } |
232 | |||
233 | #endregion | ||
224 | } | 234 | } |
225 | } \ No newline at end of file | 235 | } \ No newline at end of file |