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 | |
parent | - Evaluate config only once (diff) | |
download | opensim-SC-62c263d32b1cfb2dfc8e3681ea93f2dd33c077ca.zip opensim-SC-62c263d32b1cfb2dfc8e3681ea93f2dd33c077ca.tar.gz opensim-SC-62c263d32b1cfb2dfc8e3681ea93f2dd33c077ca.tar.bz2 opensim-SC-62c263d32b1cfb2dfc8e3681ea93f2dd33c077ca.tar.xz |
WIP: Adding a few things to PresenceModule. Not quite finished yet.
4 files changed, 101 insertions, 3 deletions
diff --git a/OpenSim/Framework/FriendRegionInfo.cs b/OpenSim/Framework/FriendRegionInfo.cs index ee308ea..7315bc5 100644 --- a/OpenSim/Framework/FriendRegionInfo.cs +++ b/OpenSim/Framework/FriendRegionInfo.cs | |||
@@ -25,11 +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 | using OpenMetaverse; | ||
29 | |||
28 | namespace OpenSim.Framework | 30 | namespace OpenSim.Framework |
29 | { | 31 | { |
30 | public class FriendRegionInfo | 32 | public class FriendRegionInfo |
31 | { | 33 | { |
32 | public bool isOnline; | 34 | public bool isOnline; |
33 | public ulong regionHandle; | 35 | public ulong regionHandle; |
36 | public UUID regionID; | ||
34 | } | 37 | } |
35 | } | 38 | } |
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index f1e2f04..5f39d8f 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs | |||
@@ -770,7 +770,15 @@ namespace OpenSim.Region.Communications.OGS1 | |||
770 | { | 770 | { |
771 | FriendRegionInfo info = new FriendRegionInfo(); | 771 | FriendRegionInfo info = new FriendRegionInfo(); |
772 | info.isOnline = (bool)respData["isOnline_" + i]; | 772 | info.isOnline = (bool)respData["isOnline_" + i]; |
773 | if (info.isOnline) info.regionHandle = Convert.ToUInt64(respData["regionHandle_" + i]); | 773 | if (info.isOnline) |
774 | { | ||
775 | // TODO remove this after the next protocol update (say, r7800?) | ||
776 | info.regionHandle = Convert.ToUInt64(respData["regionHandle_" + i]); | ||
777 | |||
778 | // accept missing id | ||
779 | if(respData.ContainsKey("regionID_" + i)) | ||
780 | UUID.TryParse((string)respData["regionID_" + i], out info.regionID); | ||
781 | } | ||
774 | 782 | ||
775 | result.Add(uuid, info); | 783 | result.Add(uuid, info); |
776 | } | 784 | } |
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(); |
diff --git a/OpenSim/Region/Interfaces/IPresenceModule.cs b/OpenSim/Region/Interfaces/IPresenceModule.cs index 2023f25..23cf064 100644 --- a/OpenSim/Region/Interfaces/IPresenceModule.cs +++ b/OpenSim/Region/Interfaces/IPresenceModule.cs | |||
@@ -35,6 +35,12 @@ namespace OpenSim.Region.Interfaces | |||
35 | { | 35 | { |
36 | public UUID userID; | 36 | public UUID userID; |
37 | public UUID regionID; | 37 | public UUID regionID; |
38 | |||
39 | public PresenceInfo(UUID userID, UUID regionID) | ||
40 | { | ||
41 | this.userID = userID; | ||
42 | this.regionID = regionID; | ||
43 | } | ||
38 | } | 44 | } |
39 | 45 | ||
40 | public delegate void PresenceChange(PresenceInfo info); | 46 | public delegate void PresenceChange(PresenceInfo info); |