diff options
author | lbsa71 | 2007-07-09 21:03:36 +0000 |
---|---|---|
committer | lbsa71 | 2007-07-09 21:03:36 +0000 |
commit | 08a1fa3f96eee5e067475da453a3770ff15780f9 (patch) | |
tree | 1ed047e466e20dcf327f8c890efbf1779ead6ad6 | |
parent | * Ignored all those autogenned build files (diff) | |
download | opensim-SC_OLD-08a1fa3f96eee5e067475da453a3770ff15780f9.zip opensim-SC_OLD-08a1fa3f96eee5e067475da453a3770ff15780f9.tar.gz opensim-SC_OLD-08a1fa3f96eee5e067475da453a3770ff15780f9.tar.bz2 opensim-SC_OLD-08a1fa3f96eee5e067475da453a3770ff15780f9.tar.xz |
* Introduced ClientManager for great justice.
-rw-r--r-- | OpenSim/Framework/General/ClientManager.cs | 31 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/PacketServer.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/PrimitiveOld.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs | 84 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 28 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneBase.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 2 |
7 files changed, 93 insertions, 59 deletions
diff --git a/OpenSim/Framework/General/ClientManager.cs b/OpenSim/Framework/General/ClientManager.cs new file mode 100644 index 0000000..5b6e7b3 --- /dev/null +++ b/OpenSim/Framework/General/ClientManager.cs | |||
@@ -0,0 +1,31 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim.Framework.Interfaces; | ||
5 | |||
6 | namespace OpenSim.Framework | ||
7 | { | ||
8 | public delegate void ForEachClientDelegate( IClientAPI client ); | ||
9 | public class ClientManager | ||
10 | { | ||
11 | private Dictionary<uint, IClientAPI> m_clientThreads; | ||
12 | |||
13 | public void ForEachClient(ForEachClientDelegate whatToDo) | ||
14 | { | ||
15 | foreach (IClientAPI client in m_clientThreads.Values) | ||
16 | { | ||
17 | whatToDo(client); | ||
18 | } | ||
19 | } | ||
20 | |||
21 | public ClientManager() | ||
22 | { | ||
23 | m_clientThreads = new Dictionary<uint, IClientAPI>(); | ||
24 | } | ||
25 | |||
26 | public void Add(uint id, IClientAPI client ) | ||
27 | { | ||
28 | m_clientThreads.Add( id, client ); | ||
29 | } | ||
30 | } | ||
31 | } | ||
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs index b5f0a02..5e62450 100644 --- a/OpenSim/Region/ClientStack/PacketServer.cs +++ b/OpenSim/Region/ClientStack/PacketServer.cs | |||
@@ -41,7 +41,7 @@ namespace OpenSim.Region.ClientStack | |||
41 | private ClientStackNetworkHandler _networkHandler; | 41 | private ClientStackNetworkHandler _networkHandler; |
42 | private IWorld _localWorld; | 42 | private IWorld _localWorld; |
43 | public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>(); | 43 | public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>(); |
44 | public Dictionary<uint, IClientAPI> ClientAPIs = new Dictionary<uint, IClientAPI>(); | 44 | public ClientManager ClientAPIs = new ClientManager(); |
45 | 45 | ||
46 | public PacketServer(ClientStackNetworkHandler networkHandler) | 46 | public PacketServer(ClientStackNetworkHandler networkHandler) |
47 | { | 47 | { |
diff --git a/OpenSim/Region/Environment/Scenes/PrimitiveOld.cs b/OpenSim/Region/Environment/Scenes/PrimitiveOld.cs index 247ff87..4933b01 100644 --- a/OpenSim/Region/Environment/Scenes/PrimitiveOld.cs +++ b/OpenSim/Region/Environment/Scenes/PrimitiveOld.cs | |||
@@ -43,7 +43,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
43 | { | 43 | { |
44 | internal PrimData primData; | 44 | internal PrimData primData; |
45 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); | 45 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); |
46 | // private Dictionary<uint, IClientAPI> m_clientThreads; | 46 | // private ClientManager m_clientThreads; |
47 | private ulong m_regionHandle; | 47 | private ulong m_regionHandle; |
48 | private const uint FULL_MASK_PERMISSIONS = 2147483647; | 48 | private const uint FULL_MASK_PERMISSIONS = 2147483647; |
49 | private bool physicsEnabled = false; | 49 | private bool physicsEnabled = false; |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 6dc9968..bb19996 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs | |||
@@ -139,48 +139,50 @@ namespace OpenSim.Region.Environment.Scenes | |||
139 | { | 139 | { |
140 | // Console.WriteLine("Chat message"); | 140 | // Console.WriteLine("Chat message"); |
141 | ScenePresence avatar = null; | 141 | ScenePresence avatar = null; |
142 | foreach (IClientAPI client in m_clientThreads.Values) | ||
143 | { | ||
144 | int dis = -1000; | ||
145 | if (this.Avatars.ContainsKey(client.AgentId)) | ||
146 | { | ||
147 | |||
148 | avatar = this.Avatars[client.AgentId]; | ||
149 | // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); | ||
150 | dis= (int)avatar.Pos.GetDistanceTo(fromPos); | ||
151 | //Console.WriteLine("found avatar at " +dis); | ||
152 | |||
153 | } | ||
154 | |||
155 | switch (type) | ||
156 | { | ||
157 | case 0: // Whisper | ||
158 | if ((dis < 10) && (dis > -10)) | ||
159 | { | ||
160 | //should change so the message is sent through the avatar rather than direct to the ClientView | ||
161 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
162 | } | ||
163 | break; | ||
164 | case 1: // Say | ||
165 | if ((dis < 30) && (dis > -30)) | ||
166 | { | ||
167 | Console.WriteLine("sending chat"); | ||
168 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
169 | } | ||
170 | break; | ||
171 | case 2: // Shout | ||
172 | if ((dis < 100) && (dis > -100)) | ||
173 | { | ||
174 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
175 | } | ||
176 | break; | ||
177 | 142 | ||
178 | case 0xff: // Broadcast | 143 | m_clientThreads.ForEachClient(delegate(IClientAPI client) |
179 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | 144 | { |
180 | break; | 145 | int dis = -1000; |
181 | } | 146 | if (this.Avatars.ContainsKey(client.AgentId)) |
182 | 147 | { | |
183 | } | 148 | avatar = this.Avatars[client.AgentId]; |
149 | // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); | ||
150 | dis = (int) avatar.Pos.GetDistanceTo(fromPos); | ||
151 | //Console.WriteLine("found avatar at " +dis); | ||
152 | } | ||
153 | |||
154 | switch (type) | ||
155 | { | ||
156 | case 0: // Whisper | ||
157 | if ((dis < 10) && (dis > -10)) | ||
158 | { | ||
159 | //should change so the message is sent through the avatar rather than direct to the ClientView | ||
160 | client.SendChatMessage(message, type, fromPos, fromName, | ||
161 | fromAgentID); | ||
162 | } | ||
163 | break; | ||
164 | case 1: // Say | ||
165 | if ((dis < 30) && (dis > -30)) | ||
166 | { | ||
167 | Console.WriteLine("sending chat"); | ||
168 | client.SendChatMessage(message, type, fromPos, fromName, | ||
169 | fromAgentID); | ||
170 | } | ||
171 | break; | ||
172 | case 2: // Shout | ||
173 | if ((dis < 100) && (dis > -100)) | ||
174 | { | ||
175 | client.SendChatMessage(message, type, fromPos, fromName, | ||
176 | fromAgentID); | ||
177 | } | ||
178 | break; | ||
179 | |||
180 | case 0xff: // Broadcast | ||
181 | client.SendChatMessage(message, type, fromPos, fromName, | ||
182 | fromAgentID); | ||
183 | break; | ||
184 | } | ||
185 | }); | ||
184 | } | 186 | } |
185 | 187 | ||
186 | /// <summary> | 188 | /// <summary> |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 5e08d53..043dcd7 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -98,7 +98,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
98 | /// <param name="clientThreads">Dictionary to contain client threads</param> | 98 | /// <param name="clientThreads">Dictionary to contain client threads</param> |
99 | /// <param name="regionHandle">Region Handle for this region</param> | 99 | /// <param name="regionHandle">Region Handle for this region</param> |
100 | /// <param name="regionName">Region Name for this region</param> | 100 | /// <param name="regionName">Region Name for this region</param> |
101 | public Scene(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer) | 101 | public Scene(ClientManager clientThreads, RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer) |
102 | { | 102 | { |
103 | updateLock = new Mutex(false); | 103 | updateLock = new Mutex(false); |
104 | this.authenticateHandler = authen; | 104 | this.authenticateHandler = authen; |
@@ -229,11 +229,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
229 | } | 229 | } |
230 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); | 230 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); |
231 | 231 | ||
232 | foreach (IClientAPI client in m_clientThreads.Values) | 232 | m_clientThreads.ForEachClient(delegate(IClientAPI client) |
233 | { | 233 | { |
234 | this.SendLayerData(client); | 234 | this.SendLayerData(client); |
235 | } | 235 | }); |
236 | 236 | ||
237 | foreach (LLUUID UUID in Entities.Keys) | 237 | foreach (LLUUID UUID in Entities.Keys) |
238 | { | 238 | { |
239 | Entities[UUID].LandRenegerated(); | 239 | Entities[UUID].LandRenegerated(); |
@@ -260,10 +260,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
260 | } | 260 | } |
261 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); | 261 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); |
262 | 262 | ||
263 | foreach (IClientAPI client in m_clientThreads.Values) | 263 | m_clientThreads.ForEachClient(delegate(IClientAPI client) |
264 | { | 264 | { |
265 | this.SendLayerData(client); | 265 | this.SendLayerData(client); |
266 | } | 266 | }); |
267 | 267 | ||
268 | foreach (LLUUID UUID in Entities.Keys) | 268 | foreach (LLUUID UUID in Entities.Keys) |
269 | { | 269 | { |
@@ -290,10 +290,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
290 | { | 290 | { |
291 | /* Dont save here, rely on tainting system instead */ | 291 | /* Dont save here, rely on tainting system instead */ |
292 | 292 | ||
293 | foreach (IClientAPI client in m_clientThreads.Values) | 293 | m_clientThreads.ForEachClient(delegate(IClientAPI client) |
294 | { | 294 | { |
295 | this.SendLayerData(pointx, pointy, client); | 295 | this.SendLayerData(pointx, pointy, client); |
296 | } | 296 | }); |
297 | } | 297 | } |
298 | } | 298 | } |
299 | catch (Exception e) | 299 | catch (Exception e) |
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index 4036743..44121b4 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs | |||
@@ -34,13 +34,14 @@ using OpenSim.Framework.Interfaces; | |||
34 | using OpenSim.Framework.Types; | 34 | using OpenSim.Framework.Types; |
35 | using OpenSim.Region.Caches; | 35 | using OpenSim.Region.Caches; |
36 | using OpenSim.Region.Terrain; | 36 | using OpenSim.Region.Terrain; |
37 | using OpenSim.Framework; | ||
37 | 38 | ||
38 | namespace OpenSim.Region.Environment.Scenes | 39 | namespace OpenSim.Region.Environment.Scenes |
39 | { | 40 | { |
40 | public abstract class SceneBase : IWorld | 41 | public abstract class SceneBase : IWorld |
41 | { | 42 | { |
42 | public Dictionary<LLUUID, EntityBase> Entities; | 43 | public Dictionary<LLUUID, EntityBase> Entities; |
43 | protected Dictionary<uint, IClientAPI> m_clientThreads; | 44 | protected ClientManager m_clientThreads; |
44 | protected ulong m_regionHandle; | 45 | protected ulong m_regionHandle; |
45 | protected string m_regionName; | 46 | protected string m_regionName; |
46 | protected RegionInfo m_regInfo; | 47 | protected RegionInfo m_regInfo; |
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs index da1b43d..b82529a 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs | |||
@@ -15,7 +15,7 @@ namespace SimpleApp | |||
15 | { | 15 | { |
16 | private List<ScenePresence> m_avatars; | 16 | private List<ScenePresence> m_avatars; |
17 | 17 | ||
18 | public MyWorld(Dictionary<uint, IClientAPI> clientThreads, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer) | 18 | public MyWorld(ClientManager clientThreads, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, BaseHttpServer httpServer) |
19 | : base(clientThreads, regionInfo, authen, commsMan, assetCach, httpServer) | 19 | : base(clientThreads, regionInfo, authen, commsMan, assetCach, httpServer) |
20 | { | 20 | { |
21 | m_avatars = new List<Avatar>(); | 21 | m_avatars = new List<Avatar>(); |