29 using System.Collections.Generic;
30 using System.Reflection;
34 using OpenSim.Framework;
35 using OpenSim.Region.Framework.Interfaces;
36 using OpenSim.Region.Framework.Scenes;
42 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"GroupsModule")]
45 private static readonly ILog m_log =
46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 private Dictionary<UUID, GroupMembershipData> m_GroupMap =
49 new Dictionary<UUID, GroupMembershipData>();
51 private Dictionary<UUID, IClientAPI> m_ClientMap =
52 new Dictionary<UUID, IClientAPI>();
54 private UUID opensimulatorGroupID =
55 new UUID(
"00000000-68f9-1111-024e-222222111123");
57 private List<Scene> m_SceneList =
new List<Scene>();
62 private bool m_Enabled =
false;
64 #region ISharedRegionModule Members
68 IConfig groupsConfig = config.Configs[
"Groups"];
70 if (groupsConfig == null)
72 m_log.Info(
"[GROUPS]: No configuration found. Using defaults");
76 m_Enabled = groupsConfig.GetBoolean(
"Enabled",
false);
79 m_log.Info(
"[GROUPS]: Groups disabled in configuration");
83 if (groupsConfig.GetString(
"Module",
"Default") !=
"Default")
99 if (!m_SceneList.Contains(scene))
101 if (m_SceneList.Count == 0)
103 osGroup.GroupID = opensimulatorGroupID;
104 osGroup.GroupName =
"OpenSimulator Testing";
105 osGroup.GroupPowers =
106 (uint)(GroupPowers.AllowLandmark |
107 GroupPowers.AllowSetHome);
108 m_GroupMap[opensimulatorGroupID] = osGroup;
110 m_SceneList.Add(scene);
114 scene.EventManager.OnNewClient += OnNewClient;
115 scene.EventManager.OnClientClosed += OnClientClosed;
126 if (m_SceneList.Contains(scene))
127 m_SceneList.Remove(scene);
130 scene.EventManager.OnNewClient -= OnNewClient;
131 scene.EventManager.OnClientClosed -= OnClientClosed;
162 get {
return "GroupsModule"; }
165 public Type ReplaceableInterface
176 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
177 client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
180 if (!m_ClientMap.ContainsKey(client.
AgentId))
182 m_ClientMap.Add(client.AgentId, client);
187 updateGroups[0] = osGroup;
189 client.SendGroupMembership(updateGroups);
192 private void OnAgentDataUpdateRequest(
IClientAPI remoteClient,
193 UUID AgentID, UUID SessionID)
196 string ActiveGroupName;
197 ulong ActiveGroupPowers;
199 string firstname = remoteClient.FirstName;
200 string lastname = remoteClient.LastName;
202 string ActiveGroupTitle =
"I IZ N0T";
204 ActiveGroupID = osGroup.GroupID;
205 ActiveGroupName = osGroup.GroupName;
206 ActiveGroupPowers = osGroup.GroupPowers;
208 remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname,
209 lastname, ActiveGroupPowers, ActiveGroupName,
223 private void HandleUUIDGroupNameRequest(UUID
id,
IClientAPI remote_client)
225 string groupnamereply =
"Unknown";
226 UUID groupUUID = UUID.Zero;
230 if (m_GroupMap.ContainsKey(
id))
233 groupnamereply = grp.GroupName;
234 groupUUID = grp.GroupID;
237 remote_client.SendGroupNameReply(groupUUID, groupnamereply);
240 private void OnClientClosed(UUID agentID,
Scene scene)
244 if (m_ClientMap.ContainsKey(agentID))
255 m_ClientMap.Remove(agentID);
void Initialise(IConfigSource config)
This is called to initialize the region module. For shared modules, this is called exactly once...
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
Interactive OpenSim region server
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...