diff options
author | MW | 2007-10-29 09:51:23 +0000 |
---|---|---|
committer | MW | 2007-10-29 09:51:23 +0000 |
commit | 27f003b68314ea5136632d6f9d14057c96ade1e1 (patch) | |
tree | 3bbdb9bb3fac97922768c2f6d0acd5dae3c4278f /OpenSim | |
parent | normalized line endings (diff) | |
download | opensim-SC_OLD-27f003b68314ea5136632d6f9d14057c96ade1e1.zip opensim-SC_OLD-27f003b68314ea5136632d6f9d14057c96ade1e1.tar.gz opensim-SC_OLD-27f003b68314ea5136632d6f9d14057c96ade1e1.tar.bz2 opensim-SC_OLD-27f003b68314ea5136632d6f9d14057c96ade1e1.tar.xz |
Started the process of cleaning up AssetCache and moving most of the code into modules. Have moved TextureRequest handling (from the client) to a module. But even though to start with I just did a little bit of cleaning up of the existing code, it doesn't seem to work as good as the old code so I need to spend more time on it. So for now am committing my changes but with them not in use. So for now all Texture and asset requests are still handled by the old code in AssetCache.
Diffstat (limited to 'OpenSim')
13 files changed, 360 insertions, 100 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index a950f51..4c18744 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs | |||
@@ -42,6 +42,8 @@ namespace OpenSim.Framework.Communications.Cache | |||
42 | { | 42 | { |
43 | public delegate void DownloadComplete(AssetCache.TextureSender sender); | 43 | public delegate void DownloadComplete(AssetCache.TextureSender sender); |
44 | 44 | ||
45 | public delegate void AssetRequestCallback(LLUUID assetID, AssetBase asset); | ||
46 | |||
45 | /// <summary> | 47 | /// <summary> |
46 | /// Manages local cache of assets and their sending to viewers. | 48 | /// Manages local cache of assets and their sending to viewers. |
47 | /// </summary> | 49 | /// </summary> |
@@ -63,6 +65,8 @@ namespace OpenSim.Framework.Communications.Cache | |||
63 | 65 | ||
64 | private Dictionary<LLUUID, Dictionary<LLUUID, int>> TimesTextureSent = new Dictionary<LLUUID, Dictionary<LLUUID, int>>(); | 66 | private Dictionary<LLUUID, Dictionary<LLUUID, int>> TimesTextureSent = new Dictionary<LLUUID, Dictionary<LLUUID, int>>(); |
65 | 67 | ||
68 | public Dictionary<LLUUID, AssetRequestsList> RequestLists = new Dictionary<LLUUID, AssetRequestsList>(); | ||
69 | |||
66 | private IAssetServer _assetServer; | 70 | private IAssetServer _assetServer; |
67 | private Thread _assetCacheThread; | 71 | private Thread _assetCacheThread; |
68 | 72 | ||
@@ -123,6 +127,46 @@ namespace OpenSim.Framework.Communications.Cache | |||
123 | return asset; | 127 | return asset; |
124 | } | 128 | } |
125 | 129 | ||
130 | public void GetAsset(LLUUID assetID, AssetRequestCallback callback) | ||
131 | { | ||
132 | AssetBase asset = null; | ||
133 | if (this.Textures.ContainsKey(assetID)) | ||
134 | { | ||
135 | asset = this.Textures[assetID]; | ||
136 | } | ||
137 | else if (this.Assets.ContainsKey(assetID)) | ||
138 | { | ||
139 | asset = this.Assets[assetID]; | ||
140 | } | ||
141 | |||
142 | if (asset != null) | ||
143 | { | ||
144 | callback(assetID, asset); | ||
145 | } | ||
146 | else | ||
147 | { | ||
148 | NewAssetRequest req = new NewAssetRequest(assetID, callback); | ||
149 | if (this.RequestLists.ContainsKey(assetID)) | ||
150 | { | ||
151 | lock (RequestLists) | ||
152 | { | ||
153 | RequestLists[assetID].Requests.Add(req); | ||
154 | } | ||
155 | } | ||
156 | else | ||
157 | { | ||
158 | AssetRequestsList reqList = new AssetRequestsList(assetID); | ||
159 | reqList.Requests.Add(req); | ||
160 | lock (RequestLists) | ||
161 | { | ||
162 | RequestLists.Add(assetID, reqList); | ||
163 | } | ||
164 | } | ||
165 | this._assetServer.FetchAsset(assetID, false); | ||
166 | } | ||
167 | } | ||
168 | |||
169 | |||
126 | public AssetBase GetAsset(LLUUID assetID, bool isTexture) | 170 | public AssetBase GetAsset(LLUUID assetID, bool isTexture) |
127 | { | 171 | { |
128 | AssetBase asset = GetAsset(assetID); | 172 | AssetBase asset = GetAsset(assetID); |
@@ -135,7 +179,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
135 | 179 | ||
136 | public void AddAsset(AssetBase asset) | 180 | public void AddAsset(AssetBase asset) |
137 | { | 181 | { |
138 | // System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); | 182 | //System.Console.WriteLine("adding asset " + asset.FullID.ToStringHyphenated()); |
139 | if (asset.Type == 0) | 183 | if (asset.Type == 0) |
140 | { | 184 | { |
141 | //Console.WriteLine("which is a texture"); | 185 | //Console.WriteLine("which is a texture"); |
@@ -207,26 +251,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
207 | while (true) | 251 | while (true) |
208 | { | 252 | { |
209 | TextureSender sender = this.QueueTextures.Dequeue(); | 253 | TextureSender sender = this.QueueTextures.Dequeue(); |
210 | /* if (TimesTextureSent.ContainsKey(sender.request.RequestUser.AgentId)) | 254 | |
211 | { | ||
212 | if (TimesTextureSent[sender.request.RequestUser.AgentId].ContainsKey(sender.request.ImageInfo.FullID)) | ||
213 | { | ||
214 | TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID]++; | ||
215 | } | ||
216 | else | ||
217 | { | ||
218 | TimesTextureSent[sender.request.RequestUser.AgentId].Add(sender.request.ImageInfo.FullID, 1); | ||
219 | } | ||
220 | } | ||
221 | else | ||
222 | { | ||
223 | Dictionary<LLUUID, int> UsersSent = new Dictionary<LLUUID,int>(); | ||
224 | TimesTextureSent.Add(sender.request.RequestUser.AgentId, UsersSent ); | ||
225 | UsersSent.Add(sender.request.ImageInfo.FullID, 1); | ||
226 | |||
227 | } | ||
228 | if (TimesTextureSent[sender.request.RequestUser.AgentId][sender.request.ImageInfo.FullID] < 1000) | ||
229 | {*/ | ||
230 | bool finished = sender.SendTexture(); | 255 | bool finished = sender.SendTexture(); |
231 | if (finished) | 256 | if (finished) |
232 | { | 257 | { |
@@ -237,11 +262,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
237 | // Console.WriteLine("readding texture"); | 262 | // Console.WriteLine("readding texture"); |
238 | this.QueueTextures.Enqueue(sender); | 263 | this.QueueTextures.Enqueue(sender); |
239 | } | 264 | } |
240 | /* } | 265 | |
241 | else | ||
242 | { | ||
243 | this.TextureSent(sender); | ||
244 | }*/ | ||
245 | } | 266 | } |
246 | } | 267 | } |
247 | 268 | ||
@@ -317,6 +338,21 @@ namespace OpenSim.Framework.Communications.Cache | |||
317 | } | 338 | } |
318 | } | 339 | } |
319 | } | 340 | } |
341 | |||
342 | if (RequestLists.ContainsKey(asset.FullID)) | ||
343 | { | ||
344 | AssetRequestsList reqList = RequestLists[asset.FullID]; | ||
345 | foreach (NewAssetRequest req in reqList.Requests) | ||
346 | { | ||
347 | req.Callback(asset.FullID, asset); | ||
348 | } | ||
349 | |||
350 | lock (RequestLists) | ||
351 | { | ||
352 | RequestLists.Remove(asset.FullID); | ||
353 | reqList.Requests.Clear(); | ||
354 | } | ||
355 | } | ||
320 | } | 356 | } |
321 | } | 357 | } |
322 | 358 | ||
@@ -508,17 +544,6 @@ namespace OpenSim.Framework.Communications.Cache | |||
508 | } | 544 | } |
509 | 545 | ||
510 | } | 546 | } |
511 | |||
512 | public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset) | ||
513 | { | ||
514 | AssetInfo newAsset = new AssetInfo(); | ||
515 | newAsset.Data = new byte[sourceAsset.Data.Length]; | ||
516 | Array.Copy(sourceAsset.Data, newAsset.Data, sourceAsset.Data.Length); | ||
517 | newAsset.FullID = LLUUID.Random(); | ||
518 | newAsset.Type = sourceAsset.Type; | ||
519 | newAsset.InvType = sourceAsset.InvType; | ||
520 | return (newAsset); | ||
521 | } | ||
522 | #endregion | 547 | #endregion |
523 | 548 | ||
524 | #region Textures | 549 | #region Textures |
@@ -529,7 +554,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
529 | /// <param name="imageID"></param> | 554 | /// <param name="imageID"></param> |
530 | public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber, int discard) | 555 | public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber, int discard) |
531 | { | 556 | { |
532 | //Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); | 557 | // System.Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber); |
533 | //check to see if texture is in local cache, if not request from asset server | 558 | //check to see if texture is in local cache, if not request from asset server |
534 | if (!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) | 559 | if (!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId)) |
535 | { | 560 | { |
@@ -540,6 +565,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
540 | //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them"); | 565 | //Console.WriteLine(userInfo.AgentId +" is requesting a image( "+ imageID+" that has already been sent to them"); |
541 | return; | 566 | return; |
542 | }*/ | 567 | }*/ |
568 | |||
543 | if (!this.Textures.ContainsKey(imageID)) | 569 | if (!this.Textures.ContainsKey(imageID)) |
544 | { | 570 | { |
545 | if (!this.RequestedTextures.ContainsKey(imageID)) | 571 | if (!this.RequestedTextures.ContainsKey(imageID)) |
@@ -556,7 +582,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
556 | return; | 582 | return; |
557 | } | 583 | } |
558 | 584 | ||
559 | //Console.WriteLine("texture already in cache"); | 585 | // System.Console.WriteLine("texture already in cache"); |
560 | TextureImage imag = this.Textures[imageID]; | 586 | TextureImage imag = this.Textures[imageID]; |
561 | AssetRequest req = new AssetRequest(); | 587 | AssetRequest req = new AssetRequest(); |
562 | req.RequestUser = userInfo; | 588 | req.RequestUser = userInfo; |
@@ -583,46 +609,9 @@ namespace OpenSim.Framework.Communications.Cache | |||
583 | this.TextureRequests.Add(req); | 609 | this.TextureRequests.Add(req); |
584 | } | 610 | } |
585 | 611 | ||
586 | public TextureImage CloneImage(LLUUID newOwner, TextureImage source) | 612 | |
587 | { | ||
588 | TextureImage newImage = new TextureImage(); | ||
589 | newImage.Data = new byte[source.Data.Length]; | ||
590 | Array.Copy(source.Data, newImage.Data, source.Data.Length); | ||
591 | //newImage.filename = source.filename; | ||
592 | newImage.FullID = LLUUID.Random(); | ||
593 | newImage.Name = source.Name; | ||
594 | return (newImage); | ||
595 | } | ||
596 | #endregion | 613 | #endregion |
597 | 614 | ||
598 | private IAssetServer LoadAssetDll(string dllName) | ||
599 | { | ||
600 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | ||
601 | IAssetServer server = null; | ||
602 | |||
603 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
604 | { | ||
605 | if (pluginType.IsPublic) | ||
606 | { | ||
607 | if (!pluginType.IsAbstract) | ||
608 | { | ||
609 | Type typeInterface = pluginType.GetInterface("IAssetPlugin", true); | ||
610 | |||
611 | if (typeInterface != null) | ||
612 | { | ||
613 | IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
614 | server = plug.GetAssetServer(); | ||
615 | break; | ||
616 | } | ||
617 | |||
618 | typeInterface = null; | ||
619 | } | ||
620 | } | ||
621 | } | ||
622 | pluginAssembly = null; | ||
623 | return server; | ||
624 | } | ||
625 | |||
626 | public class AssetRequest | 615 | public class AssetRequest |
627 | { | 616 | { |
628 | public IClientAPI RequestUser; | 617 | public IClientAPI RequestUser; |
@@ -779,4 +768,29 @@ namespace OpenSim.Framework.Communications.Cache | |||
779 | } | 768 | } |
780 | } | 769 | } |
781 | } | 770 | } |
771 | |||
772 | public class AssetRequestsList | ||
773 | { | ||
774 | public LLUUID AssetID; | ||
775 | public List<NewAssetRequest> Requests = new List<NewAssetRequest>(); | ||
776 | |||
777 | public AssetRequestsList(LLUUID assetID) | ||
778 | { | ||
779 | AssetID = assetID; | ||
780 | } | ||
781 | } | ||
782 | |||
783 | public class NewAssetRequest | ||
784 | { | ||
785 | public LLUUID AssetID; | ||
786 | public AssetRequestCallback Callback; | ||
787 | |||
788 | public NewAssetRequest(LLUUID assetID, AssetRequestCallback callback) | ||
789 | { | ||
790 | AssetID = assetID; | ||
791 | Callback = callback; | ||
792 | } | ||
793 | |||
794 | |||
795 | } | ||
782 | } | 796 | } |
diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs index 7cb18e5..8aae3c2 100644 --- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs +++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs | |||
@@ -136,6 +136,33 @@ namespace OpenSim.Framework.Interfaces | |||
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | public class TextureRequestArgs : EventArgs | ||
140 | { | ||
141 | protected LLUUID m_requestedAssetID; | ||
142 | private sbyte m_discardLevel; | ||
143 | private uint m_packetNumber; | ||
144 | |||
145 | public uint PacketNumber | ||
146 | { | ||
147 | get { return m_packetNumber; } | ||
148 | set { m_packetNumber = value; } | ||
149 | } | ||
150 | |||
151 | public sbyte DiscardLevel | ||
152 | { | ||
153 | get { return m_discardLevel; } | ||
154 | set { m_discardLevel = value; } | ||
155 | } | ||
156 | |||
157 | public LLUUID RequestedAssetID | ||
158 | { | ||
159 | get { return m_requestedAssetID; } | ||
160 | set { m_requestedAssetID = value; } | ||
161 | } | ||
162 | } | ||
163 | |||
164 | public delegate void TextureRequest(Object sender, TextureRequestArgs e); | ||
165 | |||
139 | public delegate void ImprovedInstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID, uint timestamp, string fromAgentName, string message, byte dialog); // Cut down from full list | 166 | public delegate void ImprovedInstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID, uint timestamp, string fromAgentName, string message, byte dialog); // Cut down from full list |
140 | public delegate void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos); | 167 | public delegate void RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 pos); |
141 | public delegate void ModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, IClientAPI remoteClient); | 168 | public delegate void ModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, IClientAPI remoteClient); |
@@ -204,6 +231,7 @@ namespace OpenSim.Framework.Interfaces | |||
204 | { | 231 | { |
205 | event ImprovedInstantMessage OnInstantMessage; | 232 | event ImprovedInstantMessage OnInstantMessage; |
206 | event ChatFromViewer OnChatFromViewer; | 233 | event ChatFromViewer OnChatFromViewer; |
234 | event TextureRequest OnRequestTexture; | ||
207 | event RezObject OnRezObject; | 235 | event RezObject OnRezObject; |
208 | event ModifyTerrain OnModifyTerrain; | 236 | event ModifyTerrain OnModifyTerrain; |
209 | event SetAppearance OnSetAppearance; | 237 | event SetAppearance OnSetAppearance; |
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index bb26cae..8ea9347 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs | |||
@@ -149,11 +149,6 @@ namespace OpenSim | |||
149 | 149 | ||
150 | config.Set("asset_database", "sqlite"); | 150 | config.Set("asset_database", "sqlite"); |
151 | 151 | ||
152 | // wtf? | ||
153 | config.Set("default_modules", true); | ||
154 | config.Set("default_shared_modules", true); | ||
155 | config.Set("except_modules", ""); | ||
156 | config.Set("except_shared_modules", ""); | ||
157 | } | 152 | } |
158 | 153 | ||
159 | if (m_config.Configs["StandAlone"] == null) | 154 | if (m_config.Configs["StandAlone"] == null) |
@@ -195,6 +190,7 @@ namespace OpenSim | |||
195 | m_networkServersInfo = new NetworkServersInfo(); | 190 | m_networkServersInfo = new NetworkServersInfo(); |
196 | 191 | ||
197 | IConfig startupConfig = m_config.Configs["Startup"]; | 192 | IConfig startupConfig = m_config.Configs["Startup"]; |
193 | |||
198 | if (startupConfig != null) | 194 | if (startupConfig != null) |
199 | { | 195 | { |
200 | m_sandbox = !startupConfig.GetBoolean("gridmode", false); | 196 | m_sandbox = !startupConfig.GetBoolean("gridmode", false); |
diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index 74f1824..ba8bf02 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs | |||
@@ -46,6 +46,7 @@ namespace OpenSim.Region.ClientStack | |||
46 | public event ViewerEffectEventHandler OnViewerEffect; | 46 | public event ViewerEffectEventHandler OnViewerEffect; |
47 | public event ImprovedInstantMessage OnInstantMessage; | 47 | public event ImprovedInstantMessage OnInstantMessage; |
48 | public event ChatFromViewer OnChatFromViewer; | 48 | public event ChatFromViewer OnChatFromViewer; |
49 | public event TextureRequest OnRequestTexture; | ||
49 | public event RezObject OnRezObject; | 50 | public event RezObject OnRezObject; |
50 | public event GenericCall4 OnDeRezObject; | 51 | public event GenericCall4 OnDeRezObject; |
51 | public event ModifyTerrain OnModifyTerrain; | 52 | public event ModifyTerrain OnModifyTerrain; |
diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index 65a0e44..8a1a520 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs | |||
@@ -210,7 +210,7 @@ namespace OpenSim.Region.ClientStack | |||
210 | case PacketType.AgentSit: | 210 | case PacketType.AgentSit: |
211 | if (OnAgentSit != null) | 211 | if (OnAgentSit != null) |
212 | { | 212 | { |
213 | AgentSitPacket agentSit = (AgentSitPacket) Pack; | 213 | AgentSitPacket agentSit = (AgentSitPacket)Pack; |
214 | OnAgentSit(this, agentSit.AgentData.AgentID); | 214 | OnAgentSit(this, agentSit.AgentData.AgentID); |
215 | } | 215 | } |
216 | break; | 216 | break; |
@@ -364,7 +364,17 @@ namespace OpenSim.Region.ClientStack | |||
364 | for (int i = 0; i < imageRequest.RequestImage.Length; i++) | 364 | for (int i = 0; i < imageRequest.RequestImage.Length; i++) |
365 | { | 365 | { |
366 | 366 | ||
367 | // Console.WriteLine("image request of "+ imageRequest.RequestImage[i].Image+ " at discard level " + imageRequest.RequestImage[i].DiscardLevel); | 367 | // still working on the Texture download module so for now using old method |
368 | // TextureRequestArgs args = new TextureRequestArgs(); | ||
369 | // args.RequestedAssetID = imageRequest.RequestImage[i].Image; | ||
370 | // args.DiscardLevel = imageRequest.RequestImage[i].DiscardLevel; | ||
371 | // args.PacketNumber = imageRequest.RequestImage[i].Packet; | ||
372 | |||
373 | // if (OnRequestTexture != null) | ||
374 | // { | ||
375 | // OnRequestTexture(this, args); | ||
376 | // } | ||
377 | |||
368 | m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image, imageRequest.RequestImage[i].Packet, imageRequest.RequestImage[i].DiscardLevel); | 378 | m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image, imageRequest.RequestImage[i].Packet, imageRequest.RequestImage[i].DiscardLevel); |
369 | } | 379 | } |
370 | break; | 380 | break; |
diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index 160b740..442ee77 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs | |||
@@ -79,6 +79,9 @@ namespace OpenSim.Region.Environment | |||
79 | 79 | ||
80 | AvatarFactoryModule avatarFactory = new AvatarFactoryModule(); | 80 | AvatarFactoryModule avatarFactory = new AvatarFactoryModule(); |
81 | LoadedSharedModules.Add(avatarFactory.Name, avatarFactory); | 81 | LoadedSharedModules.Add(avatarFactory.Name, avatarFactory); |
82 | |||
83 | //TextureDownloadModule textureModule = new TextureDownloadModule(); | ||
84 | //LoadedSharedModules.Add(textureModule.Name, textureModule); | ||
82 | } | 85 | } |
83 | 86 | ||
84 | public void InitialiseSharedModules(Scene scene) | 87 | public void InitialiseSharedModules(Scene scene) |
diff --git a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs index 440d948..3ce3e4e 100644 --- a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs | |||
@@ -62,7 +62,7 @@ namespace OpenSim.Region.Environment.Modules | |||
62 | 62 | ||
63 | public bool IsSharedModule | 63 | public bool IsSharedModule |
64 | { | 64 | { |
65 | get { return false; } | 65 | get { return true; } |
66 | } | 66 | } |
67 | 67 | ||
68 | public void NewClient(IClientAPI client) | 68 | public void NewClient(IClientAPI client) |
diff --git a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs index 7c4e2c8..77ff24b 100644 --- a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs +++ b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs | |||
@@ -39,14 +39,17 @@ namespace OpenSim.Region.Environment.Modules | |||
39 | private List<Scene> m_scenes = new List<Scene>(); | 39 | private List<Scene> m_scenes = new List<Scene>(); |
40 | private LogBase m_log; | 40 | private LogBase m_log; |
41 | 41 | ||
42 | public InstantMessageModule() | ||
43 | { | ||
44 | m_log = OpenSim.Framework.Console.MainLog.Instance; | ||
45 | } | ||
46 | |||
42 | public void Initialise(Scene scene, IConfigSource config) | 47 | public void Initialise(Scene scene, IConfigSource config) |
43 | { | 48 | { |
44 | if (!m_scenes.Contains(scene)) | 49 | if (!m_scenes.Contains(scene)) |
45 | { | 50 | { |
46 | m_scenes.Add(scene); | 51 | m_scenes.Add(scene); |
47 | 52 | scene.EventManager.OnNewClient += OnNewClient; | |
48 | scene.EventManager.OnNewClient += OnNewClient; | ||
49 | m_log = OpenSim.Framework.Console.MainLog.Instance; | ||
50 | } | 53 | } |
51 | } | 54 | } |
52 | 55 | ||
@@ -69,9 +72,11 @@ namespace OpenSim.Region.Environment.Modules | |||
69 | { | 72 | { |
70 | // Local Message | 73 | // Local Message |
71 | ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; | 74 | ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; |
72 | user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, | 75 | if (!user.IsChildAgent) |
73 | toAgentID, imSessionID, user.Firstname + " " + user.Lastname, dialog, timestamp); | 76 | { |
74 | 77 | user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, | |
78 | toAgentID, imSessionID, fromAgentName, dialog, timestamp); | ||
79 | } | ||
75 | // Message sent | 80 | // Message sent |
76 | return; | 81 | return; |
77 | } | 82 | } |
diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs index d3297c8..56e20d1 100644 --- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs | |||
@@ -25,9 +25,14 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | using System; | |
29 | using System.Collections.Generic; | ||
30 | using System.Threading; | ||
29 | using libsecondlife; | 31 | using libsecondlife; |
32 | using libsecondlife.Packets; | ||
30 | using OpenSim.Framework.Interfaces; | 33 | using OpenSim.Framework.Interfaces; |
34 | using OpenSim.Framework.Types; | ||
35 | using OpenSim.Framework.Utilities; | ||
31 | using OpenSim.Region.Environment.Interfaces; | 36 | using OpenSim.Region.Environment.Interfaces; |
32 | using OpenSim.Region.Environment.Scenes; | 37 | using OpenSim.Region.Environment.Scenes; |
33 | using Nini.Config; | 38 | using Nini.Config; |
@@ -37,15 +42,28 @@ namespace OpenSim.Region.Environment.Modules | |||
37 | public class TextureDownloadModule : IRegionModule | 42 | public class TextureDownloadModule : IRegionModule |
38 | { | 43 | { |
39 | private Scene m_scene; | 44 | private Scene m_scene; |
45 | private List<Scene> m_scenes = new List<Scene>(); | ||
46 | private Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>> ClientRequests = new Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>>(); | ||
47 | |||
48 | private BlockingQueue<TextureSender> QueueSenders = new BlockingQueue<TextureSender>(); | ||
49 | private Dictionary<LLUUID, List<LLUUID>> InProcess = new Dictionary<LLUUID, List<LLUUID>>(); | ||
50 | // private Thread m_thread; | ||
40 | 51 | ||
41 | public TextureDownloadModule() | 52 | public TextureDownloadModule() |
42 | { | 53 | { |
54 | // m_thread = new Thread(new ThreadStart(ProcessTextureSenders)); | ||
55 | // m_thread.IsBackground = true; | ||
56 | // m_thread.Start(); | ||
43 | } | 57 | } |
44 | 58 | ||
45 | public void Initialise(Scene scene, IConfigSource config) | 59 | public void Initialise(Scene scene, IConfigSource config) |
46 | { | 60 | { |
47 | m_scene = scene; | 61 | if (!m_scenes.Contains(scene)) |
48 | m_scene.EventManager.OnNewClient += NewClient; | 62 | { |
63 | m_scenes.Add(scene); | ||
64 | m_scene = scene; | ||
65 | m_scene.EventManager.OnNewClient += NewClient; | ||
66 | } | ||
49 | } | 67 | } |
50 | 68 | ||
51 | public void PostInitialise() | 69 | public void PostInitialise() |
@@ -63,15 +81,184 @@ namespace OpenSim.Region.Environment.Modules | |||
63 | 81 | ||
64 | public bool IsSharedModule | 82 | public bool IsSharedModule |
65 | { | 83 | { |
66 | get { return false; } | 84 | get { return true; } |
67 | } | 85 | } |
68 | 86 | ||
69 | public void NewClient(IClientAPI client) | 87 | public void NewClient(IClientAPI client) |
70 | { | 88 | { |
89 | /* lock (ClientRequests) | ||
90 | { | ||
91 | if (!ClientRequests.ContainsKey(client.AgentId)) | ||
92 | { | ||
93 | ClientRequests.Add(client.AgentId, new Dictionary<LLUUID, AssetRequest>()); | ||
94 | InProcess.Add(client.AgentId, new List<LLUUID>()); | ||
95 | } | ||
96 | } | ||
97 | client.OnRequestTexture += TextureRequest; | ||
98 | */ | ||
99 | } | ||
100 | |||
101 | public void TextureCallback(LLUUID textureID, AssetBase asset) | ||
102 | { | ||
103 | lock (ClientRequests) | ||
104 | { | ||
105 | foreach (Dictionary<LLUUID, AssetRequest> reqList in ClientRequests.Values) | ||
106 | { | ||
107 | if (reqList.ContainsKey(textureID)) | ||
108 | { | ||
109 | //check the texture isn't already in the process of being sent to the client. | ||
110 | if (!InProcess[reqList[textureID].RequestUser.AgentId].Contains(textureID)) | ||
111 | { | ||
112 | TextureSender sender = new TextureSender(reqList[textureID], asset); | ||
113 | QueueSenders.Enqueue(sender); | ||
114 | InProcess[reqList[textureID].RequestUser.AgentId].Add(textureID); | ||
115 | reqList.Remove(textureID); | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | } | ||
120 | } | ||
121 | |||
122 | public void TextureRequest(Object sender, TextureRequestArgs e) | ||
123 | { | ||
124 | IClientAPI client = (IClientAPI)sender; | ||
125 | if (!ClientRequests[client.AgentId].ContainsKey(e.RequestedAssetID)) | ||
126 | { | ||
127 | lock (ClientRequests) | ||
128 | { | ||
129 | AssetRequest request = new AssetRequest(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber); | ||
130 | ClientRequests[client.AgentId].Add(e.RequestedAssetID, request); | ||
131 | } | ||
132 | m_scene.commsManager.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback); | ||
133 | } | ||
134 | } | ||
135 | |||
136 | public void ProcessTextureSenders() | ||
137 | { | ||
138 | while (true) | ||
139 | { | ||
140 | TextureSender sender = this.QueueSenders.Dequeue(); | ||
141 | bool finished = sender.SendTexture(); | ||
142 | if (finished) | ||
143 | { | ||
144 | this.TextureSent(sender); | ||
145 | } | ||
146 | else | ||
147 | { | ||
148 | this.QueueSenders.Enqueue(sender); | ||
149 | } | ||
150 | } | ||
151 | } | ||
152 | |||
153 | private void TextureSent(TextureSender sender) | ||
154 | { | ||
155 | if (InProcess[sender.request.RequestUser.AgentId].Contains(sender.request.RequestAssetID)) | ||
156 | { | ||
157 | InProcess[sender.request.RequestUser.AgentId].Remove(sender.request.RequestAssetID); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | public class TextureSender | ||
162 | { | ||
163 | public AssetRequest request; | ||
164 | private int counter = 0; | ||
165 | private AssetBase m_asset; | ||
166 | public long DataPointer = 0; | ||
167 | public int NumPackets = 0; | ||
168 | public int PacketCounter = 0; | ||
169 | |||
170 | public TextureSender(AssetRequest req, AssetBase asset) | ||
171 | { | ||
172 | request = req; | ||
173 | m_asset = asset; | ||
174 | |||
175 | if (asset.Data.LongLength > 600) | ||
176 | { | ||
177 | NumPackets = 2 + (int)(asset.Data.Length - 601) / 1000; | ||
178 | } | ||
179 | else | ||
180 | { | ||
181 | NumPackets = 1; | ||
182 | } | ||
183 | |||
184 | PacketCounter = (int) req.PacketNumber; | ||
185 | } | ||
186 | |||
187 | public bool SendTexture() | ||
188 | { | ||
189 | SendPacket(); | ||
190 | counter++; | ||
191 | if ((PacketCounter >= NumPackets) | counter > 100 | (NumPackets == 1) | (request.DiscardLevel == -1)) | ||
192 | { | ||
193 | return true; | ||
194 | } | ||
195 | return false; | ||
196 | } | ||
197 | |||
198 | public void SendPacket() | ||
199 | { | ||
200 | AssetRequest req = request; | ||
201 | if (PacketCounter == 0) | ||
202 | { | ||
203 | if (NumPackets == 1) | ||
204 | { | ||
205 | ImageDataPacket im = new ImageDataPacket(); | ||
206 | im.Header.Reliable = false; | ||
207 | im.ImageID.Packets = 1; | ||
208 | im.ImageID.ID = m_asset.FullID; | ||
209 | im.ImageID.Size = (uint)m_asset.Data.Length; | ||
210 | im.ImageData.Data = m_asset.Data; | ||
211 | im.ImageID.Codec = 2; | ||
212 | req.RequestUser.OutPacket(im); | ||
213 | PacketCounter++; | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | ImageDataPacket im = new ImageDataPacket(); | ||
218 | im.Header.Reliable = false; | ||
219 | im.ImageID.Packets = (ushort)(NumPackets); | ||
220 | im.ImageID.ID = m_asset.FullID; | ||
221 | im.ImageID.Size = (uint)m_asset.Data.Length; | ||
222 | im.ImageData.Data = new byte[600]; | ||
223 | Array.Copy(m_asset.Data, 0, im.ImageData.Data, 0, 600); | ||
224 | im.ImageID.Codec = 2; | ||
225 | req.RequestUser.OutPacket(im); | ||
226 | PacketCounter++; | ||
227 | } | ||
228 | } | ||
229 | else | ||
230 | { | ||
231 | ImagePacketPacket im = new ImagePacketPacket(); | ||
232 | im.Header.Reliable = false; | ||
233 | im.ImageID.Packet = (ushort)(PacketCounter); | ||
234 | im.ImageID.ID = m_asset.FullID; | ||
235 | int size = m_asset.Data.Length - 600 - (1000 * (PacketCounter - 1)); | ||
236 | if (size > 1000) size = 1000; | ||
237 | im.ImageData.Data = new byte[size]; | ||
238 | Array.Copy(m_asset.Data, 600 + (1000 * (PacketCounter - 1)), im.ImageData.Data, 0, size); | ||
239 | req.RequestUser.OutPacket(im); | ||
240 | PacketCounter++; | ||
241 | } | ||
242 | |||
243 | } | ||
244 | |||
71 | } | 245 | } |
72 | 246 | ||
73 | public void TextureAssetCallback(LLUUID texture, byte[] data) | 247 | public class AssetRequest |
74 | { | 248 | { |
249 | public IClientAPI RequestUser; | ||
250 | public LLUUID RequestAssetID; | ||
251 | public int DiscardLevel = -1; | ||
252 | public uint PacketNumber = 0; | ||
253 | |||
254 | public AssetRequest(IClientAPI client, LLUUID textureID, int discardLevel, uint packetNumber) | ||
255 | { | ||
256 | RequestUser = client; | ||
257 | RequestAssetID = textureID; | ||
258 | DiscardLevel = discardLevel; | ||
259 | PacketNumber = packetNumber; | ||
260 | } | ||
75 | } | 261 | } |
262 | |||
76 | } | 263 | } |
77 | } | 264 | } |
diff --git a/OpenSim/Region/Environment/Modules/WorldCommModule.cs b/OpenSim/Region/Environment/Modules/WorldCommModule.cs index cf5bba3..c7e0f8f 100644 --- a/OpenSim/Region/Environment/Modules/WorldCommModule.cs +++ b/OpenSim/Region/Environment/Modules/WorldCommModule.cs | |||
@@ -87,13 +87,11 @@ namespace OpenSim.Region.Environment.Modules | |||
87 | 87 | ||
88 | public void Initialise(Scene scene, IConfigSource config) | 88 | public void Initialise(Scene scene, IConfigSource config) |
89 | { | 89 | { |
90 | |||
91 | m_scene = scene; | 90 | m_scene = scene; |
92 | m_scene.RegisterModuleInterface<IWorldComm>(this); | 91 | m_scene.RegisterModuleInterface<IWorldComm>(this); |
93 | m_listenerManager = new ListenerManager(); | 92 | m_listenerManager = new ListenerManager(); |
94 | m_pending = new Queue<ListenerInfo>(); | 93 | m_pending = new Queue<ListenerInfo>(); |
95 | m_scene.EventManager.OnNewClient += NewClient; | 94 | m_scene.EventManager.OnNewClient += NewClient; |
96 | |||
97 | } | 95 | } |
98 | 96 | ||
99 | public void PostInitialise() | 97 | public void PostInitialise() |
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs index 7db6927..76ff6cf 100644 --- a/OpenSim/Region/Environment/Scenes/SceneManager.cs +++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs | |||
@@ -274,6 +274,23 @@ namespace OpenSim.Region.Environment.Scenes | |||
274 | return false; | 274 | return false; |
275 | } | 275 | } |
276 | 276 | ||
277 | public bool TryGetAvatarsScene(LLUUID avatarId, out Scene scene) | ||
278 | { | ||
279 | ScenePresence avatar = null; | ||
280 | foreach (Scene mScene in m_localScenes) | ||
281 | { | ||
282 | if (mScene.TryGetAvatar(avatarId, out avatar)) | ||
283 | { | ||
284 | scene = mScene; | ||
285 | return true; | ||
286 | } | ||
287 | } | ||
288 | |||
289 | scene = null; | ||
290 | return false; | ||
291 | } | ||
292 | |||
293 | |||
277 | public void CloseScene(Scene scene) | 294 | public void CloseScene(Scene scene) |
278 | { | 295 | { |
279 | m_localScenes.Remove(scene); | 296 | m_localScenes.Remove(scene); |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 58d2157..a0d1d2a 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -125,7 +125,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
125 | set { m_name = value; } | 125 | set { m_name = value; } |
126 | } | 126 | } |
127 | 127 | ||
128 | protected LLObject.ObjectFlags m_flags; | 128 | protected LLObject.ObjectFlags m_flags =0; |
129 | 129 | ||
130 | public uint ObjectFlags | 130 | public uint ObjectFlags |
131 | { | 131 | { |
@@ -133,7 +133,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
133 | set { m_flags = (LLObject.ObjectFlags) value; } | 133 | set { m_flags = (LLObject.ObjectFlags) value; } |
134 | } | 134 | } |
135 | 135 | ||
136 | protected LLObject.MaterialType m_material; | 136 | protected LLObject.MaterialType m_material =0; |
137 | 137 | ||
138 | public byte Material | 138 | public byte Material |
139 | { | 139 | { |
diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index 7962698..b935f24 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs | |||
@@ -53,6 +53,7 @@ namespace SimpleApp | |||
53 | 53 | ||
54 | public event ImprovedInstantMessage OnInstantMessage; | 54 | public event ImprovedInstantMessage OnInstantMessage; |
55 | public event ChatFromViewer OnChatFromViewer; | 55 | public event ChatFromViewer OnChatFromViewer; |
56 | public event TextureRequest OnRequestTexture; | ||
56 | public event RezObject OnRezObject; | 57 | public event RezObject OnRezObject; |
57 | public event ModifyTerrain OnModifyTerrain; | 58 | public event ModifyTerrain OnModifyTerrain; |
58 | public event SetAppearance OnSetAppearance; | 59 | public event SetAppearance OnSetAppearance; |