diff options
author | Homer Horwitz | 2008-11-24 22:07:45 +0000 |
---|---|---|
committer | Homer Horwitz | 2008-11-24 22:07:45 +0000 |
commit | 62c263d32b1cfb2dfc8e3681ea93f2dd33c077ca (patch) | |
tree | 9d67fa434c0025ee08248c8296282c1772ad5ec0 /OpenSim/Region/Environment/Modules | |
parent | - Evaluate config only once (diff) | |
download | opensim-SC_OLD-62c263d32b1cfb2dfc8e3681ea93f2dd33c077ca.zip opensim-SC_OLD-62c263d32b1cfb2dfc8e3681ea93f2dd33c077ca.tar.gz opensim-SC_OLD-62c263d32b1cfb2dfc8e3681ea93f2dd33c077ca.tar.bz2 opensim-SC_OLD-62c263d32b1cfb2dfc8e3681ea93f2dd33c077ca.tar.xz |
WIP: Adding a few things to PresenceModule. Not quite finished yet.
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/InstantMessage/PresenceModule.cs | 85 |
1 files changed, 83 insertions, 2 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/PresenceModule.cs index 28ed991..4ec80e5 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/PresenceModule.cs | |||
@@ -48,6 +48,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage | |||
48 | 48 | ||
49 | private bool m_Enabled = false; | 49 | private bool m_Enabled = false; |
50 | private bool m_Gridmode = false; | 50 | private bool m_Gridmode = false; |
51 | |||
52 | // some default scene for doing things that aren't connected to a specific scene. Avoids locking. | ||
53 | private Scene m_initialScene; | ||
54 | |||
51 | private List<Scene> m_Scenes = new List<Scene>(); | 55 | private List<Scene> m_Scenes = new List<Scene>(); |
52 | 56 | ||
53 | private Dictionary<UUID, Scene> m_RootAgents = | 57 | private Dictionary<UUID, Scene> m_RootAgents = |
@@ -75,6 +79,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage | |||
75 | m_Gridmode = cnf.GetBoolean("gridmode", false); | 79 | m_Gridmode = cnf.GetBoolean("gridmode", false); |
76 | 80 | ||
77 | m_Enabled = true; | 81 | m_Enabled = true; |
82 | |||
83 | m_initialScene = scene; | ||
78 | } | 84 | } |
79 | 85 | ||
80 | if (m_Gridmode) | 86 | if (m_Gridmode) |
@@ -84,6 +90,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage | |||
84 | 90 | ||
85 | scene.EventManager.OnNewClient += OnNewClient; | 91 | scene.EventManager.OnNewClient += OnNewClient; |
86 | scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene; | 92 | scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene; |
93 | //scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; | ||
87 | 94 | ||
88 | m_Scenes.Add(scene); | 95 | m_Scenes.Add(scene); |
89 | } | 96 | } |
@@ -98,8 +105,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage | |||
98 | if (!m_Gridmode || !m_Enabled) | 105 | if (!m_Gridmode || !m_Enabled) |
99 | return; | 106 | return; |
100 | 107 | ||
101 | foreach (Scene scene in m_Scenes) | 108 | lock (m_Scenes) |
102 | NotifyMessageServerOfShutdown(scene); | 109 | { |
110 | foreach (Scene scene in m_Scenes) | ||
111 | NotifyMessageServerOfShutdown(scene); | ||
112 | } | ||
103 | } | 113 | } |
104 | 114 | ||
105 | public string Name | 115 | public string Name |
@@ -114,6 +124,58 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage | |||
114 | 124 | ||
115 | public void RequestBulkPresenceData(UUID[] users) | 125 | public void RequestBulkPresenceData(UUID[] users) |
116 | { | 126 | { |
127 | if (OnBulkPresenceData != null) | ||
128 | { | ||
129 | PresenceInfo[] result = new PresenceInfo[users.Length]; | ||
130 | if (m_Gridmode) | ||
131 | { | ||
132 | // TODO process local info first and only do a server lookup if necessary. | ||
133 | // TODO fix m_RootAgents contents. Currently, they won't work right in a | ||
134 | // non standalone server. Consider two servers, with one sim each in a | ||
135 | // 2x1 grid. Clients will never be closed, just the root moves from | ||
136 | // server to server. But it stays in m_RootAgents on both servers. | ||
137 | Dictionary<UUID, FriendRegionInfo> infos = m_initialScene.GetFriendRegionInfos(new List<UUID>(users)); | ||
138 | for (int i = 0; i < users.Length; ++i) | ||
139 | { | ||
140 | FriendRegionInfo info; | ||
141 | if (infos.TryGetValue(users[i], out info) && info.isOnline) | ||
142 | { | ||
143 | UUID regionID = info.regionID; | ||
144 | if (regionID == UUID.Zero) | ||
145 | { | ||
146 | // TODO this is the old messaging-server protocol; only the regionHandle is available. | ||
147 | // Fetch region-info to get the id | ||
148 | RegionInfo regionInfo = m_initialScene.RequestNeighbouringRegionInfo(info.regionHandle); | ||
149 | regionID = regionInfo.RegionID; | ||
150 | } | ||
151 | result[i] = new PresenceInfo(users[i], regionID); | ||
152 | } | ||
153 | else result[i] = new PresenceInfo(users[i], UUID.Zero); | ||
154 | } | ||
155 | } | ||
156 | else | ||
157 | { | ||
158 | // in standalone mode, we have all the info locally available. | ||
159 | lock (m_RootAgents) | ||
160 | { | ||
161 | for (int i = 0; i < users.Length; ++i) | ||
162 | { | ||
163 | Scene scene; | ||
164 | if (m_RootAgents.TryGetValue(users[i], out scene)) | ||
165 | { | ||
166 | result[i] = new PresenceInfo(users[i], scene.RegionInfo.RegionID); | ||
167 | } | ||
168 | else | ||
169 | { | ||
170 | result[i] = new PresenceInfo(users[i], UUID.Zero); | ||
171 | } | ||
172 | } | ||
173 | } | ||
174 | } | ||
175 | |||
176 | // tell everyone | ||
177 | OnBulkPresenceData(result); | ||
178 | } | ||
117 | } | 179 | } |
118 | 180 | ||
119 | public void OnNewClient(IClientAPI client) | 181 | public void OnNewClient(IClientAPI client) |
@@ -160,6 +222,25 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage | |||
160 | NotifyMessageServerOfAgentLocation(agentID, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); | 222 | NotifyMessageServerOfAgentLocation(agentID, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); |
161 | } | 223 | } |
162 | 224 | ||
225 | // TODO not sure about that yet | ||
226 | // public void OnMakeChildAgent(ScenePresence agent) | ||
227 | // { | ||
228 | // // OnMakeChildAgent can be called from several threads at once (with different agent). | ||
229 | // // Concurrent access to m_RootAgents is prone to failure on multi-core/-processor systems without | ||
230 | // // correct locking). | ||
231 | // lock (m_RootAgents) | ||
232 | // { | ||
233 | // Scene rootScene; | ||
234 | // if (m_RootAgents.TryGetValue(agentID, out rootScene) && agent.Scene == rootScene) | ||
235 | // { | ||
236 | // m_RootAgents[agentID] = scene; | ||
237 | // } | ||
238 | // } | ||
239 | // // don't notify the messaging-server; either this is just downgraded and another one will be upgraded | ||
240 | // // to root momentarily (which will notify the messaging-server), or possibly it will be closed in a moment, | ||
241 | // // which will update the messaging-server, too. | ||
242 | // } | ||
243 | |||
163 | private void NotifyMessageServerOfStartup(Scene scene) | 244 | private void NotifyMessageServerOfStartup(Scene scene) |
164 | { | 245 | { |
165 | Hashtable xmlrpcdata = new Hashtable(); | 246 | Hashtable xmlrpcdata = new Hashtable(); |