aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment')
-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
7 files changed, 226 insertions, 16 deletions
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 {