aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMW2007-10-29 09:51:23 +0000
committerMW2007-10-29 09:51:23 +0000
commit27f003b68314ea5136632d6f9d14057c96ade1e1 (patch)
tree3bbdb9bb3fac97922768c2f6d0acd5dae3c4278f /OpenSim/Region
parentnormalized line endings (diff)
downloadopensim-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/Region')
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs6
-rw-r--r--OpenSim/Region/ClientStack/ClientView.API.cs1
-rw-r--r--OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs14
-rw-r--r--OpenSim/Region/Environment/ModuleLoader.cs3
-rw-r--r--OpenSim/Region/Environment/Modules/AssetDownloadModule.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/InstantMessageModule.cs17
-rw-r--r--OpenSim/Region/Environment/Modules/TextureDownloadModule.cs197
-rw-r--r--OpenSim/Region/Environment/Modules/WorldCommModule.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneManager.cs17
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs4
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs1
11 files changed, 241 insertions, 23 deletions
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 28using System;
29using System.Collections.Generic;
30using System.Threading;
29using libsecondlife; 31using libsecondlife;
32using libsecondlife.Packets;
30using OpenSim.Framework.Interfaces; 33using OpenSim.Framework.Interfaces;
34using OpenSim.Framework.Types;
35using OpenSim.Framework.Utilities;
31using OpenSim.Region.Environment.Interfaces; 36using OpenSim.Region.Environment.Interfaces;
32using OpenSim.Region.Environment.Scenes; 37using OpenSim.Region.Environment.Scenes;
33using Nini.Config; 38using 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;