aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules
diff options
context:
space:
mode:
authorTeravus Ovares2008-02-20 09:45:26 +0000
committerTeravus Ovares2008-02-20 09:45:26 +0000
commitac60382599d8a2bfcf431c0eeafd65eebf865e21 (patch)
tree9ea29e29c93e1ce5a3d962f26ed00388c9253315 /OpenSim/Region/Environment/Modules
parent* Fixed xml loading bug (the xml was scheduled for update before added to a s... (diff)
downloadopensim-SC_OLD-ac60382599d8a2bfcf431c0eeafd65eebf865e21.zip
opensim-SC_OLD-ac60382599d8a2bfcf431c0eeafd65eebf865e21.tar.gz
opensim-SC_OLD-ac60382599d8a2bfcf431c0eeafd65eebf865e21.tar.bz2
opensim-SC_OLD-ac60382599d8a2bfcf431c0eeafd65eebf865e21.tar.xz
* Added a few more packets to ClientView. Added tendons to the Skeletal Groups Module, made it shared to save on threads.
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rw-r--r--OpenSim/Region/Environment/Modules/GroupsModule.cs223
1 files changed, 220 insertions, 3 deletions
diff --git a/OpenSim/Region/Environment/Modules/GroupsModule.cs b/OpenSim/Region/Environment/Modules/GroupsModule.cs
index 50e9a39..6eb3cda 100644
--- a/OpenSim/Region/Environment/Modules/GroupsModule.cs
+++ b/OpenSim/Region/Environment/Modules/GroupsModule.cs
@@ -27,18 +27,182 @@
27*/ 27*/
28 28
29using Nini.Config; 29using Nini.Config;
30using System;
31using System.Collections;
32using System.Collections.Generic;
33using OpenSim.Framework;
34using OpenSim.Framework.Console;
30using OpenSim.Region.Environment.Interfaces; 35using OpenSim.Region.Environment.Interfaces;
31using OpenSim.Region.Environment.Scenes; 36using OpenSim.Region.Environment.Scenes;
37using libsecondlife;
32 38
33namespace OpenSim.Region.Environment.Modules 39namespace OpenSim.Region.Environment.Modules
34{ 40{
35 public class GroupsModule : IRegionModule 41 public class GroupsModule : IRegionModule
36 { 42 {
37 private Scene m_scene; 43 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
44
45 private List<Scene> m_scene = new List<Scene>();
46 private Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>();
47 private Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>();
48 private Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>();
38 49
39 public void Initialise(Scene scene, IConfigSource config) 50 public void Initialise(Scene scene, IConfigSource config)
40 { 51 {
41 m_scene = scene; 52 lock (m_scene)
53 {
54 m_scene.Add(scene);
55 }
56 scene.EventManager.OnNewClient += OnNewClient;
57 scene.EventManager.OnClientClosed += OnClientClosed;
58 scene.EventManager.OnGridInstantMessageToGroupsModule += OnGridInstantMessage;
59 //scene.EventManager.
60 }
61 private void OnNewClient(IClientAPI client)
62 {
63 // All friends establishment protocol goes over instant message
64 // There's no way to send a message from the sim
65 // to a user to 'add a friend' without causing dialog box spam
66 //
67 // The base set of friends are added when the user signs on in their XMLRPC response
68 // Generated by LoginService. The friends are retreived from the database by the UserManager
69
70 // Subscribe to instant messages
71 client.OnInstantMessage += OnInstantMessage;
72 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
73 lock (m_iclientmap)
74 {
75 if (!m_iclientmap.ContainsKey(client.AgentId))
76 {
77 m_iclientmap.Add(client.AgentId, client);
78 }
79 }
80 GroupData OpenSimulatorGroup = new GroupData();
81 OpenSimulatorGroup.ActiveGroupTitle = "OpenSimulator Tester";
82 OpenSimulatorGroup.GroupID = new LLUUID("00000000-68f9-1111-024e-222222111120");
83 OpenSimulatorGroup.GroupMembers.Add(client.AgentId);
84 OpenSimulatorGroup.groupName = "OpenSimulator Testing";
85 OpenSimulatorGroup.ActiveGroupPowers = GroupPowers.LandAllowSetHome;
86 OpenSimulatorGroup.GroupTitles.Add("OpenSimulator Tester");
87 lock (m_groupmap)
88 {
89 if (!m_groupmap.ContainsKey(client.AgentId))
90 {
91 m_groupmap.Add(client.AgentId, OpenSimulatorGroup);
92 }
93 }
94 GroupList testGroupList = new GroupList();
95 testGroupList.m_GroupList.Add(new LLUUID("00000000-68f9-1111-024e-222222111120"));
96
97 lock (m_grouplistmap)
98 {
99 if (!m_grouplistmap.ContainsKey(client.AgentId))
100 {
101 m_grouplistmap.Add(client.AgentId, testGroupList);
102 }
103 }
104 m_log.Info("[GROUP]: Adding " + client.FirstName + " " + client.LastName + " to OpenSimulator Tester group");
105
106
107 }
108
109 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, LLUUID AgentID, LLUUID SessionID)
110 {
111 string firstname = remoteClient.FirstName;
112 string lastname = remoteClient.LastName;
113
114 LLUUID ActiveGroupID = LLUUID.Zero;
115 uint ActiveGroupPowers = 0;
116 string ActiveGroupName = "";
117 string ActiveGroupTitle = "";
118
119 bool foundUser = false;
120
121 lock (m_iclientmap)
122 {
123 if (m_iclientmap.ContainsKey(remoteClient.AgentId))
124 {
125 foundUser = true;
126 }
127 }
128 if (foundUser)
129 {
130 lock (m_groupmap)
131 {
132 if (m_groupmap.ContainsKey(remoteClient.AgentId))
133 {
134 GroupData grp = m_groupmap[remoteClient.AgentId];
135 if (grp != null)
136 {
137 ActiveGroupID = grp.GroupID;
138 ActiveGroupName = grp.groupName;
139 ActiveGroupPowers = grp.groupPowers;
140 ActiveGroupTitle = grp.ActiveGroupTitle;
141 }
142
143 //remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, lastname, ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle);
144
145 }
146 }
147 }
148
149 }
150
151 private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID,
152 LLUUID fromAgentSession, LLUUID toAgentID,
153 LLUUID imSessionID, uint timestamp, string fromAgentName,
154 string message, byte dialog, bool fromGroup, byte offline,
155 uint ParentEstateID, LLVector3 Position, LLUUID RegionID,
156 byte[] binaryBucket)
157 {
158
159 }
160
161 private void OnGridInstantMessage(GridInstantMessage msg)
162 {
163 // Trigger the above event handler
164 OnInstantMessage(null, new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession),
165 new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName,
166 msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID,
167 new LLVector3(msg.Position.x, msg.Position.y, msg.Position.z), new LLUUID(msg.RegionID),
168 msg.binaryBucket);
169 }
170
171 private void OnClientClosed(LLUUID agentID)
172 {
173 lock (m_iclientmap)
174 {
175 if (m_iclientmap.ContainsKey(agentID))
176 {
177 IClientAPI cli = m_iclientmap[agentID];
178 if (cli != null)
179 {
180 m_log.Info("[GROUP]: Removing all reference to groups for " + cli.FirstName + " " + cli.LastName);
181 }
182 else
183 {
184 m_log.Info("[GROUP]: Removing all reference to groups for " + agentID.ToString());
185 }
186 m_iclientmap.Remove(agentID);
187 }
188 }
189
190 lock (m_groupmap)
191 {
192 if (m_groupmap.ContainsKey(agentID))
193 {
194 m_groupmap.Remove(agentID);
195 }
196 }
197
198 lock (m_grouplistmap)
199 {
200 if (m_grouplistmap.ContainsKey(agentID))
201 {
202 m_grouplistmap.Remove(agentID);
203 }
204 }
205 GC.Collect();
42 } 206 }
43 207
44 public void PostInitialise() 208 public void PostInitialise()
@@ -47,6 +211,22 @@ namespace OpenSim.Region.Environment.Modules
47 211
48 public void Close() 212 public void Close()
49 { 213 {
214 m_log.Info("[GROUP]: Shutting down group module.");
215 lock (m_iclientmap)
216 {
217 m_iclientmap.Clear();
218 }
219
220 lock (m_groupmap)
221 {
222 m_groupmap.Clear();
223 }
224
225 lock (m_grouplistmap)
226 {
227 m_grouplistmap.Clear();
228 }
229 GC.Collect();
50 } 230 }
51 231
52 public string Name 232 public string Name
@@ -56,7 +236,44 @@ namespace OpenSim.Region.Environment.Modules
56 236
57 public bool IsSharedModule 237 public bool IsSharedModule
58 { 238 {
59 get { return false; } 239 get { return true; }
240 }
241
242 }
243 public class GroupData
244 {
245 public LLUUID GroupID;
246 public string groupName;
247 public string ActiveGroupTitle;
248 public List<string> GroupTitles;
249 public List<LLUUID> GroupMembers;
250 public uint groupPowers = (uint)(GroupPowers.LandAllowLandmark | GroupPowers.LandAllowSetHome);
251
252 public GroupPowers ActiveGroupPowers
253 {
254 set
255 {
256 groupPowers = (uint) value;
257 }
258 get
259 {
260 return (GroupPowers)groupPowers;
261 }
262 }
263
264 public GroupData()
265 {
266 GroupTitles = new List<string>();
267 GroupMembers = new List<LLUUID>();
268 }
269
270 }
271 public class GroupList
272 {
273 public List<LLUUID> m_GroupList;
274 public GroupList()
275 {
276 m_GroupList = new List<LLUUID>();
60 } 277 }
61 } 278 }
62} \ No newline at end of file 279} \ No newline at end of file