diff options
author | Teravus Ovares | 2008-06-02 16:16:07 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-06-02 16:16:07 +0000 |
commit | 3991908db5b50e764112d30e5750447db67795b5 (patch) | |
tree | bc5c47d6c26b87dd04c550ed24d5597e686e7663 | |
parent | Fixed half completed comment in OpenSim.ini.example. (diff) | |
download | opensim-SC_OLD-3991908db5b50e764112d30e5750447db67795b5.zip opensim-SC_OLD-3991908db5b50e764112d30e5750447db67795b5.tar.gz opensim-SC_OLD-3991908db5b50e764112d30e5750447db67795b5.tar.bz2 opensim-SC_OLD-3991908db5b50e764112d30e5750447db67795b5.tar.xz |
* This update enables grid wide presence updates.
* You'll need to start-up the MessageingServer and set it up. It sets up like any of the other grid servers.
* All user presence data is kept in memory for speed, while the agent is online. That means if you shutdown the messaging server or the messaging server crashes, it forgets who's online/offline.
* Occasionally the region-cache will get stale if regions move around a lot. if it gets stale, run clear-cache on the messaging server console to clear the region cache.
-rw-r--r-- | OpenSim/Framework/MessageServerConfig.cs | 9 | ||||
-rw-r--r-- | OpenSim/Framework/UserConfig.cs | 4 | ||||
-rw-r--r-- | OpenSim/Grid/MessagingServer/Main.cs | 22 | ||||
-rw-r--r-- | OpenSim/Grid/MessagingServer/MessageService.cs | 155 | ||||
-rw-r--r-- | OpenSim/Grid/MessagingServer/PresenceInformer.cs | 81 | ||||
-rw-r--r-- | OpenSim/Grid/MessagingServer/UserPresenceData.cs | 1 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer/MessageServersConnector.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | 8 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs | 132 |
9 files changed, 374 insertions, 44 deletions
diff --git a/OpenSim/Framework/MessageServerConfig.cs b/OpenSim/Framework/MessageServerConfig.cs index c378d27..7a50c91 100644 --- a/OpenSim/Framework/MessageServerConfig.cs +++ b/OpenSim/Framework/MessageServerConfig.cs | |||
@@ -38,6 +38,7 @@ namespace OpenSim.Framework | |||
38 | public static bool DefaultHttpSSL = false; | 38 | public static bool DefaultHttpSSL = false; |
39 | private ConfigurationMember configMember; | 39 | private ConfigurationMember configMember; |
40 | public string DatabaseProvider = String.Empty; | 40 | public string DatabaseProvider = String.Empty; |
41 | public string DatabaseConnect = String.Empty; | ||
41 | public string DefaultStartupMsg = String.Empty; | 42 | public string DefaultStartupMsg = String.Empty; |
42 | public string GridCommsProvider = String.Empty; | 43 | public string GridCommsProvider = String.Empty; |
43 | public string GridRecvKey = String.Empty; | 44 | public string GridRecvKey = String.Empty; |
@@ -76,6 +77,11 @@ namespace OpenSim.Framework | |||
76 | configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | 77 | configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, |
77 | "Key to expect from user server", "null", false); | 78 | "Key to expect from user server", "null", false); |
78 | 79 | ||
80 | |||
81 | configMember.addConfigurationOption("database_connect", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | ||
82 | "Connection String for Database", "", false); | ||
83 | |||
84 | |||
79 | configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | 85 | configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, |
80 | "DLL for database provider", "OpenSim.Data.MySQL.dll", false); | 86 | "DLL for database provider", "OpenSim.Data.MySQL.dll", false); |
81 | 87 | ||
@@ -115,6 +121,9 @@ namespace OpenSim.Framework | |||
115 | case "database_provider": | 121 | case "database_provider": |
116 | DatabaseProvider = (string) configuration_result; | 122 | DatabaseProvider = (string) configuration_result; |
117 | break; | 123 | break; |
124 | case "database_connect": | ||
125 | DatabaseConnect = (string)configuration_result; | ||
126 | break; | ||
118 | case "http_port": | 127 | case "http_port": |
119 | HttpPort = (uint) configuration_result; | 128 | HttpPort = (uint) configuration_result; |
120 | break; | 129 | break; |
diff --git a/OpenSim/Framework/UserConfig.cs b/OpenSim/Framework/UserConfig.cs index 3c0bdfa..3cb0503 100644 --- a/OpenSim/Framework/UserConfig.cs +++ b/OpenSim/Framework/UserConfig.cs | |||
@@ -49,6 +49,10 @@ namespace OpenSim.Framework | |||
49 | public bool HttpSSL = DefaultHttpSSL; | 49 | public bool HttpSSL = DefaultHttpSSL; |
50 | public string InventoryUrl = String.Empty; | 50 | public string InventoryUrl = String.Empty; |
51 | 51 | ||
52 | public UserConfig() | ||
53 | { | ||
54 | // weird, but UserManagerBase needs this. | ||
55 | } | ||
52 | public UserConfig(string description, string filename) | 56 | public UserConfig(string description, string filename) |
53 | { | 57 | { |
54 | configMember = | 58 | configMember = |
diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs index d2fa659..91f2101 100644 --- a/OpenSim/Grid/MessagingServer/Main.cs +++ b/OpenSim/Grid/MessagingServer/Main.cs | |||
@@ -31,7 +31,9 @@ using System.Reflection; | |||
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using log4net; | 32 | using log4net; |
33 | using log4net.Config; | 33 | using log4net.Config; |
34 | |||
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Framework.Console; | 37 | using OpenSim.Framework.Console; |
36 | using OpenSim.Framework.Servers; | 38 | using OpenSim.Framework.Servers; |
37 | 39 | ||
@@ -88,6 +90,8 @@ namespace OpenSim.Grid.MessagingServer | |||
88 | m_log.Info("[REGION]: Starting HTTP process"); | 90 | m_log.Info("[REGION]: Starting HTTP process"); |
89 | m_httpServer = new BaseHttpServer(Cfg.HttpPort); | 91 | m_httpServer = new BaseHttpServer(Cfg.HttpPort); |
90 | 92 | ||
93 | |||
94 | |||
91 | msgsvc = new MessageService(Cfg); | 95 | msgsvc = new MessageService(Cfg); |
92 | 96 | ||
93 | if (msgsvc.registerWithUserServer()) | 97 | if (msgsvc.registerWithUserServer()) |
@@ -144,6 +148,24 @@ namespace OpenSim.Grid.MessagingServer | |||
144 | } | 148 | } |
145 | } | 149 | } |
146 | 150 | ||
151 | public override void RunCmd(string cmd, string[] cmdparams) | ||
152 | { | ||
153 | base.RunCmd(cmd, cmdparams); | ||
154 | |||
155 | switch (cmd) | ||
156 | { | ||
157 | case "help": | ||
158 | m_console.Notice("clear-cache - Clears region cache. Should be done when regions change position. The region cache gets stale after a while."); | ||
159 | break; | ||
160 | case "clear-cache": | ||
161 | int entries = msgsvc.ClearRegionCache(); | ||
162 | m_console.Notice("Region cache cleared! Cleared " + entries.ToString() + " entries"); | ||
163 | break; | ||
164 | } | ||
165 | |||
166 | |||
167 | } | ||
168 | |||
147 | public override void Shutdown() | 169 | public override void Shutdown() |
148 | { | 170 | { |
149 | msgsvc.deregisterWithUserServer(); | 171 | msgsvc.deregisterWithUserServer(); |
diff --git a/OpenSim/Grid/MessagingServer/MessageService.cs b/OpenSim/Grid/MessagingServer/MessageService.cs index e1beef1..59fef7e 100644 --- a/OpenSim/Grid/MessagingServer/MessageService.cs +++ b/OpenSim/Grid/MessagingServer/MessageService.cs | |||
@@ -46,6 +46,7 @@ namespace OpenSim.Grid.MessagingServer | |||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | private MessageServerConfig m_cfg; | 48 | private MessageServerConfig m_cfg; |
49 | private UserManager m_userManager; | ||
49 | 50 | ||
50 | //A hashtable of all current presences this server knows about | 51 | //A hashtable of all current presences this server knows about |
51 | private Hashtable m_presences = new Hashtable(); | 52 | private Hashtable m_presences = new Hashtable(); |
@@ -62,11 +63,16 @@ namespace OpenSim.Grid.MessagingServer | |||
62 | public MessageService(MessageServerConfig cfg) | 63 | public MessageService(MessageServerConfig cfg) |
63 | { | 64 | { |
64 | m_cfg = cfg; | 65 | m_cfg = cfg; |
66 | m_userManager = new UserManager(); | ||
67 | UserConfig uc = new UserConfig(); | ||
68 | uc.DatabaseConnect = cfg.DatabaseConnect; | ||
69 | uc.DatabaseProvider = cfg.DatabaseProvider; | ||
70 | |||
71 | m_userManager._config = uc; | ||
72 | m_userManager.AddPlugin(cfg.DatabaseProvider, cfg.DatabaseConnect); | ||
65 | } | 73 | } |
66 | 74 | ||
67 | #region RegionComms Methods | 75 | |
68 | |||
69 | #endregion | ||
70 | 76 | ||
71 | #region FriendList Methods | 77 | #region FriendList Methods |
72 | 78 | ||
@@ -123,11 +129,27 @@ namespace OpenSim.Grid.MessagingServer | |||
123 | { | 129 | { |
124 | // we need to send out online status update, but the user is already subscribed | 130 | // we need to send out online status update, but the user is already subscribed |
125 | } | 131 | } |
126 | PresenceInformer friendlistupdater = new PresenceInformer(); | 132 | UserAgentData p2Handle = m_userManager.GetUserAgentData(userpresence.agentData.AgentID); |
127 | friendlistupdater.presence1 = friendpresence; | 133 | if (p2Handle != null) |
128 | friendlistupdater.presence2 = userpresence; | 134 | { |
129 | WaitCallback cb = new WaitCallback(friendlistupdater.go); | 135 | |
130 | ThreadPool.QueueUserWorkItem(cb); | 136 | userpresence.regionData.regionHandle = p2Handle.Handle; |
137 | PresenceInformer friendlistupdater = new PresenceInformer(); | ||
138 | friendlistupdater.presence1 = friendpresence; | ||
139 | //friendlistupdater.gridserverurl = m_cfg.GridServerURL; | ||
140 | //friendlistupdater.gridserversendkey = m_cfg.GridSendKey; | ||
141 | //friendlistupdater.gridserverrecvkey = m_cfg.GridRecvKey; | ||
142 | friendlistupdater.presence2 = userpresence; | ||
143 | friendlistupdater.OnGetRegionData += GetRegionInfo; | ||
144 | friendlistupdater.OnDone += PresenceUpdateDone; | ||
145 | WaitCallback cb = new WaitCallback(friendlistupdater.go); | ||
146 | ThreadPool.QueueUserWorkItem(cb); | ||
147 | |||
148 | } | ||
149 | else | ||
150 | { | ||
151 | // Skip because we can't find any data on the user | ||
152 | } | ||
131 | 153 | ||
132 | //SendRegionPresenceUpdate(friendpresence, userpresence); | 154 | //SendRegionPresenceUpdate(friendpresence, userpresence); |
133 | } | 155 | } |
@@ -143,12 +165,30 @@ namespace OpenSim.Grid.MessagingServer | |||
143 | { | 165 | { |
144 | // we need to send out online status update, but the user is already subscribed | 166 | // we need to send out online status update, but the user is already subscribed |
145 | } | 167 | } |
146 | PresenceInformer friendlistupdater = new PresenceInformer(); | 168 | |
147 | friendlistupdater.presence1 = userpresence; | 169 | UserAgentData p2Handle = m_userManager.GetUserAgentData(friendpresence.agentData.AgentID); |
148 | friendlistupdater.presence2 = friendpresence; | ||
149 | 170 | ||
150 | WaitCallback cb2 = new WaitCallback(friendlistupdater.go); | 171 | if (p2Handle != null) |
151 | ThreadPool.QueueUserWorkItem(cb2); | 172 | { |
173 | |||
174 | friendpresence.regionData.regionHandle = p2Handle.Handle; | ||
175 | PresenceInformer friendlistupdater = new PresenceInformer(); | ||
176 | friendlistupdater.presence1 = userpresence; | ||
177 | friendlistupdater.presence2 = friendpresence; | ||
178 | //friendlistupdater.gridserverurl = m_cfg.GridServerURL; | ||
179 | //friendlistupdater.gridserversendkey = m_cfg.GridSendKey; | ||
180 | //friendlistupdater.gridserverrecvkey = m_cfg.GridRecvKey; | ||
181 | friendlistupdater.OnGetRegionData += GetRegionInfo; | ||
182 | friendlistupdater.OnDone += PresenceUpdateDone; | ||
183 | WaitCallback cb2 = new WaitCallback(friendlistupdater.go); | ||
184 | ThreadPool.QueueUserWorkItem(cb2); | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | // skip, agent doesn't appear to exist anymore | ||
189 | } | ||
190 | |||
191 | |||
152 | 192 | ||
153 | //SendRegionPresenceUpdate(userpresence, friendpresence); | 193 | //SendRegionPresenceUpdate(userpresence, friendpresence); |
154 | } | 194 | } |
@@ -209,6 +249,7 @@ namespace OpenSim.Grid.MessagingServer | |||
209 | /// <param name="AgentID"></param> | 249 | /// <param name="AgentID"></param> |
210 | private void ProcessLogOff(LLUUID AgentID) | 250 | private void ProcessLogOff(LLUUID AgentID) |
211 | { | 251 | { |
252 | m_log.Info("[LOGOFF]: Processing Logoff"); | ||
212 | UserPresenceData AgentData = null; | 253 | UserPresenceData AgentData = null; |
213 | List<LLUUID> AgentsNeedingNotification = new List<LLUUID>(); | 254 | List<LLUUID> AgentsNeedingNotification = new List<LLUUID>(); |
214 | UserPresenceData friendd = null; | 255 | UserPresenceData friendd = null; |
@@ -223,6 +264,7 @@ namespace OpenSim.Grid.MessagingServer | |||
223 | if (AgentData != null) | 264 | if (AgentData != null) |
224 | { | 265 | { |
225 | AgentsNeedingNotification = AgentData.subscriptionData; | 266 | AgentsNeedingNotification = AgentData.subscriptionData; |
267 | AgentData.OnlineYN = false; | ||
226 | //lock (m_presence_BackReferences) | 268 | //lock (m_presence_BackReferences) |
227 | //{ | 269 | //{ |
228 | //if (m_presence_BackReferences.Contains(AgentID)) | 270 | //if (m_presence_BackReferences.Contains(AgentID)) |
@@ -262,13 +304,33 @@ namespace OpenSim.Grid.MessagingServer | |||
262 | m_presences[AgentsNeedingNotification[i]] = friendd; | 304 | m_presences[AgentsNeedingNotification[i]] = friendd; |
263 | } | 305 | } |
264 | 306 | ||
265 | PresenceInformer friendlistupdater = new PresenceInformer(); | 307 | UserAgentData p2Handle = m_userManager.GetUserAgentData(friendd.agentData.AgentID); |
266 | friendlistupdater.presence1 = AgentData; | 308 | if (p2Handle != null) |
267 | friendlistupdater.presence2 = friendd; | 309 | { |
310 | |||
311 | |||
312 | friendd.regionData.regionHandle = p2Handle.Handle; | ||
313 | PresenceInformer friendlistupdater = new PresenceInformer(); | ||
314 | friendlistupdater.presence1 = AgentData; | ||
315 | friendlistupdater.presence2 = friendd; | ||
316 | |||
317 | //friendlistupdater.gridserverurl = m_cfg.GridServerURL; | ||
318 | //friendlistupdater.gridserversendkey = m_cfg.GridSendKey; | ||
319 | //friendlistupdater.gridserverrecvkey = m_cfg.GridRecvKey; | ||
320 | |||
321 | friendlistupdater.OnGetRegionData += GetRegionInfo; | ||
322 | friendlistupdater.OnDone += PresenceUpdateDone; | ||
323 | |||
324 | WaitCallback cb3 = new WaitCallback(friendlistupdater.go); | ||
325 | ThreadPool.QueueUserWorkItem(cb3); | ||
268 | 326 | ||
269 | WaitCallback cb3 = new WaitCallback(friendlistupdater.go); | 327 | |
270 | ThreadPool.QueueUserWorkItem(cb3); | ||
271 | 328 | ||
329 | } | ||
330 | else | ||
331 | { | ||
332 | // skip, agent can't be found | ||
333 | } | ||
272 | //SendRegionPresenceUpdate(AgentData, friendd); | 334 | //SendRegionPresenceUpdate(AgentData, friendd); |
273 | 335 | ||
274 | //removeBackReference(AgentID, AgentsNeedingNotification[i]); | 336 | //removeBackReference(AgentID, AgentsNeedingNotification[i]); |
@@ -279,6 +341,12 @@ namespace OpenSim.Grid.MessagingServer | |||
279 | 341 | ||
280 | #endregion | 342 | #endregion |
281 | 343 | ||
344 | public void PresenceUpdateDone(PresenceInformer obj) | ||
345 | { | ||
346 | obj.OnGetRegionData -= GetRegionInfo; | ||
347 | obj.OnDone -= PresenceUpdateDone; | ||
348 | } | ||
349 | |||
282 | #region UserServer Comms | 350 | #region UserServer Comms |
283 | 351 | ||
284 | /// <summary> | 352 | /// <summary> |
@@ -393,7 +461,7 @@ namespace OpenSim.Grid.MessagingServer | |||
393 | up.friendData = flData; | 461 | up.friendData = flData; |
394 | RegionProfileData riData = GetRegionInfo(regionHandle); | 462 | RegionProfileData riData = GetRegionInfo(regionHandle); |
395 | up.regionData = riData; | 463 | up.regionData = riData; |
396 | 464 | up.OnlineYN = true; | |
397 | ProcessFriendListSubscriptions(up); | 465 | ProcessFriendListSubscriptions(up); |
398 | 466 | ||
399 | return new XmlRpcResponse(); | 467 | return new XmlRpcResponse(); |
@@ -407,6 +475,7 @@ namespace OpenSim.Grid.MessagingServer | |||
407 | /// <returns></returns> | 475 | /// <returns></returns> |
408 | public XmlRpcResponse UserLoggedOff(XmlRpcRequest request) | 476 | public XmlRpcResponse UserLoggedOff(XmlRpcRequest request) |
409 | { | 477 | { |
478 | m_log.Info("[USERLOGOFF]: User logged off called"); | ||
410 | Hashtable requestData = (Hashtable)request.Params[0]; | 479 | Hashtable requestData = (Hashtable)request.Params[0]; |
411 | 480 | ||
412 | LLUUID AgentID = new LLUUID((string)requestData["agentid"]); | 481 | LLUUID AgentID = new LLUUID((string)requestData["agentid"]); |
@@ -423,23 +492,64 @@ namespace OpenSim.Grid.MessagingServer | |||
423 | /// <summary> | 492 | /// <summary> |
424 | /// Gets and caches a RegionInfo object from the gridserver based on regionhandle | 493 | /// Gets and caches a RegionInfo object from the gridserver based on regionhandle |
425 | /// if the regionhandle is already cached, use the cached values | 494 | /// if the regionhandle is already cached, use the cached values |
495 | /// Gets called by lots of threads!!!!! | ||
426 | /// </summary> | 496 | /// </summary> |
427 | /// <param name="regionhandle">handle to the XY of the region we're looking for</param> | 497 | /// <param name="regionhandle">handle to the XY of the region we're looking for</param> |
428 | /// <returns>A RegionInfo object to stick in the presence info</returns> | 498 | /// <returns>A RegionInfo object to stick in the presence info</returns> |
429 | public RegionProfileData GetRegionInfo(ulong regionhandle) | 499 | public RegionProfileData GetRegionInfo(ulong regionhandle) |
430 | { | 500 | { |
431 | RegionProfileData regionInfo = null; | 501 | RegionProfileData regionInfo = null; |
432 | if (m_regionInfoCache.Contains(regionhandle)) | 502 | bool lookup = false; |
503 | |||
504 | lock (m_regionInfoCache) | ||
433 | { | 505 | { |
434 | regionInfo = (RegionProfileData)m_regionInfoCache[regionhandle]; | 506 | if (m_regionInfoCache.Contains(regionhandle)) |
507 | { | ||
508 | regionInfo = (RegionProfileData)m_regionInfoCache[regionhandle]; | ||
509 | } | ||
510 | else | ||
511 | { | ||
512 | // Don't lock the cache while we're looking up the region! | ||
513 | lookup = true; | ||
514 | } | ||
435 | } | 515 | } |
436 | else | 516 | |
517 | if (lookup) | ||
437 | { | 518 | { |
438 | regionInfo = RequestRegionInfo(regionhandle); | 519 | regionInfo = RequestRegionInfo(regionhandle); |
520 | |||
521 | if (regionInfo != null) | ||
522 | { | ||
523 | lock (m_regionInfoCache) | ||
524 | { | ||
525 | if (m_regionInfoCache.Contains(regionhandle)) | ||
526 | { | ||
527 | m_regionInfoCache[regionhandle] = regionInfo; | ||
528 | } | ||
529 | else | ||
530 | { | ||
531 | m_regionInfoCache.Add(regionhandle, regionInfo); | ||
532 | } | ||
533 | } | ||
534 | } | ||
439 | } | 535 | } |
536 | |||
440 | return regionInfo; | 537 | return regionInfo; |
441 | } | 538 | } |
442 | 539 | ||
540 | public int ClearRegionCache() | ||
541 | { | ||
542 | int cachecount = 0; | ||
543 | |||
544 | lock (m_regionInfoCache) | ||
545 | { | ||
546 | cachecount = m_regionInfoCache.Count; | ||
547 | m_regionInfoCache.Clear(); | ||
548 | } | ||
549 | |||
550 | return cachecount; | ||
551 | } | ||
552 | |||
443 | /// <summary> | 553 | /// <summary> |
444 | /// Get RegionProfileData from the GridServer | 554 | /// Get RegionProfileData from the GridServer |
445 | /// We'll Cache this information and use it for presence updates | 555 | /// We'll Cache this information and use it for presence updates |
@@ -541,6 +651,7 @@ namespace OpenSim.Grid.MessagingServer | |||
541 | // Process Response | 651 | // Process Response |
542 | if (GridRespData.ContainsKey("responsestring")) | 652 | if (GridRespData.ContainsKey("responsestring")) |
543 | { | 653 | { |
654 | |||
544 | return true; | 655 | return true; |
545 | } | 656 | } |
546 | else | 657 | else |
diff --git a/OpenSim/Grid/MessagingServer/PresenceInformer.cs b/OpenSim/Grid/MessagingServer/PresenceInformer.cs index 59d0e13..050d88a 100644 --- a/OpenSim/Grid/MessagingServer/PresenceInformer.cs +++ b/OpenSim/Grid/MessagingServer/PresenceInformer.cs | |||
@@ -27,16 +27,31 @@ | |||
27 | 27 | ||
28 | using System.Collections; | 28 | using System.Collections; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Net; | ||
30 | using log4net; | 31 | using log4net; |
31 | using Nwc.XmlRpc; | 32 | using Nwc.XmlRpc; |
32 | using OpenSim.Data; | 33 | using OpenSim.Data; |
33 | 34 | ||
34 | namespace OpenSim.Grid.MessagingServer | 35 | namespace OpenSim.Grid.MessagingServer |
35 | { | 36 | { |
37 | public delegate RegionProfileData GetRegionData(ulong region_handle); | ||
38 | public delegate void Done(PresenceInformer obj); | ||
39 | |||
40 | |||
36 | public class PresenceInformer | 41 | public class PresenceInformer |
37 | { | 42 | { |
43 | public event GetRegionData OnGetRegionData; | ||
44 | public event Done OnDone; | ||
45 | |||
46 | private GetRegionData handlerGetRegionData = null; | ||
47 | private Done handlerDone = null; | ||
48 | |||
38 | public UserPresenceData presence1 = null; | 49 | public UserPresenceData presence1 = null; |
39 | public UserPresenceData presence2 = null; | 50 | public UserPresenceData presence2 = null; |
51 | public string gridserverurl, gridserversendkey, gridserverrecvkey; | ||
52 | public bool lookupRegion = true; | ||
53 | //public methodGroup | ||
54 | |||
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 56 | ||
42 | public PresenceInformer() | 57 | public PresenceInformer() |
@@ -60,18 +75,68 @@ namespace OpenSim.Grid.MessagingServer | |||
60 | public void SendRegionPresenceUpdate(UserPresenceData TalkingAbout, UserPresenceData UserToUpdate) | 75 | public void SendRegionPresenceUpdate(UserPresenceData TalkingAbout, UserPresenceData UserToUpdate) |
61 | { | 76 | { |
62 | // TODO: Fill in pertenant Presence Data from 'TalkingAbout' | 77 | // TODO: Fill in pertenant Presence Data from 'TalkingAbout' |
78 | RegionProfileData whichRegion = new RegionProfileData(); | ||
79 | if (lookupRegion) | ||
80 | { | ||
81 | handlerGetRegionData = OnGetRegionData; | ||
82 | if (handlerGetRegionData != null) | ||
83 | { | ||
84 | whichRegion = handlerGetRegionData(UserToUpdate.regionData.regionHandle); | ||
85 | } | ||
86 | //RegionProfileData rp = RegionProfileData.RequestSimProfileData(UserToUpdate.regionData.regionHandle, gridserverurl, gridserversendkey, gridserverrecvkey); | ||
63 | 87 | ||
64 | RegionProfileData whichRegion = UserToUpdate.regionData; | 88 | //whichRegion = rp; |
89 | } | ||
90 | else | ||
91 | { | ||
92 | whichRegion = UserToUpdate.regionData; | ||
93 | } | ||
65 | //whichRegion.httpServerURI | 94 | //whichRegion.httpServerURI |
66 | 95 | ||
67 | Hashtable PresenceParams = new Hashtable(); | 96 | if (whichRegion != null) |
68 | ArrayList SendParams = new ArrayList(); | 97 | { |
69 | SendParams.Add(PresenceParams); | 98 | |
99 | |||
100 | Hashtable PresenceParams = new Hashtable(); | ||
101 | PresenceParams.Add("agent_id",TalkingAbout.agentData.AgentID.ToString()); | ||
102 | PresenceParams.Add("notify_id",UserToUpdate.agentData.AgentID.ToString()); | ||
103 | if (TalkingAbout.OnlineYN) | ||
104 | PresenceParams.Add("status","TRUE"); | ||
105 | else | ||
106 | PresenceParams.Add("status","FALSE"); | ||
107 | |||
108 | |||
109 | |||
110 | |||
111 | ArrayList SendParams = new ArrayList(); | ||
112 | SendParams.Add(PresenceParams); | ||
113 | |||
114 | |||
115 | m_log.Info("[PRESENCE]: Informing " + whichRegion.regionName + " at " + whichRegion.httpServerURI); | ||
116 | // Send | ||
117 | XmlRpcRequest RegionReq = new XmlRpcRequest("presence_update", SendParams); | ||
118 | try | ||
119 | { | ||
120 | |||
121 | XmlRpcResponse RegionResp = RegionReq.Send(whichRegion.httpServerURI, 6000); | ||
122 | } | ||
123 | catch (WebException) | ||
124 | { | ||
125 | m_log.WarnFormat("[INFORM]: failed notifying region {0} containing user {1} about {2}", whichRegion.regionName, UserToUpdate.agentData.firstname + " " + UserToUpdate.agentData.lastname, TalkingAbout.agentData.firstname + " " + TalkingAbout.agentData.lastname); | ||
126 | } | ||
127 | } | ||
128 | else | ||
129 | { | ||
130 | m_log.Info("[PRESENCEUPDATER]: Region data was null skipping"); | ||
131 | |||
132 | } | ||
133 | |||
134 | handlerDone = OnDone; | ||
135 | if (handlerDone != null) | ||
136 | { | ||
137 | handlerDone(this); | ||
138 | } | ||
70 | 139 | ||
71 | m_log.Info("[PRESENCE]: Informing " + whichRegion.regionName + " at " + whichRegion.httpServerURI); | ||
72 | // Send | ||
73 | XmlRpcRequest RegionReq = new XmlRpcRequest("presence_update", SendParams); | ||
74 | XmlRpcResponse RegionResp = RegionReq.Send(whichRegion.httpServerURI, 6000); | ||
75 | } | 140 | } |
76 | } | 141 | } |
77 | } | 142 | } |
diff --git a/OpenSim/Grid/MessagingServer/UserPresenceData.cs b/OpenSim/Grid/MessagingServer/UserPresenceData.cs index 7188201..74a6032 100644 --- a/OpenSim/Grid/MessagingServer/UserPresenceData.cs +++ b/OpenSim/Grid/MessagingServer/UserPresenceData.cs | |||
@@ -40,6 +40,7 @@ namespace OpenSim.Grid.MessagingServer | |||
40 | public string httpURI = String.Empty; | 40 | public string httpURI = String.Empty; |
41 | public List<FriendListItem> friendData = new List<FriendListItem> (); | 41 | public List<FriendListItem> friendData = new List<FriendListItem> (); |
42 | public List<LLUUID> subscriptionData = new List<LLUUID>(); | 42 | public List<LLUUID> subscriptionData = new List<LLUUID>(); |
43 | public bool OnlineYN = false; | ||
43 | 44 | ||
44 | public UserPresenceData() | 45 | public UserPresenceData() |
45 | { | 46 | { |
diff --git a/OpenSim/Grid/UserServer/MessageServersConnector.cs b/OpenSim/Grid/UserServer/MessageServersConnector.cs index 529c089..208131e 100644 --- a/OpenSim/Grid/UserServer/MessageServersConnector.cs +++ b/OpenSim/Grid/UserServer/MessageServersConnector.cs | |||
@@ -185,12 +185,12 @@ namespace OpenSim.Grid.UserServer | |||
185 | { | 185 | { |
186 | if (MessageServers.Count > 0) | 186 | if (MessageServers.Count > 0) |
187 | { | 187 | { |
188 | m_log.Info("[MSGCONNECTOR]: Sending login notice to registered message servers"); | 188 | m_log.Info("[MSGCONNECTOR]: Sending logoff notice to registered message servers"); |
189 | } | 189 | } |
190 | else | 190 | else |
191 | // { | 191 | { |
192 | // m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); | 192 | // m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); |
193 | // } | 193 | } |
194 | foreach (MessageServerInfo serv in MessageServers.Values) | 194 | foreach (MessageServerInfo serv in MessageServers.Values) |
195 | { | 195 | { |
196 | NotifyMessageServerAboutUserLogoff(serv,agentID); | 196 | NotifyMessageServerAboutUserLogoff(serv,agentID); |
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 2e892c2..0daabc5 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | |||
@@ -382,7 +382,13 @@ namespace OpenSim.Region.Communications.OGS1 | |||
382 | regionInfo.RegionID = new LLUUID((string) responseData["region_UUID"]); | 382 | regionInfo.RegionID = new LLUUID((string) responseData["region_UUID"]); |
383 | regionInfo.RegionName = (string) responseData["region_name"]; | 383 | regionInfo.RegionName = (string) responseData["region_name"]; |
384 | 384 | ||
385 | m_remoteRegionInfoCache.Add(regionHandle, regionInfo); | 385 | lock (m_remoteRegionInfoCache) |
386 | { | ||
387 | if (!m_remoteRegionInfoCache.ContainsKey(regionHandle)) | ||
388 | { | ||
389 | m_remoteRegionInfoCache.Add(regionHandle, regionInfo); | ||
390 | } | ||
391 | } | ||
386 | } | 392 | } |
387 | catch (WebException) | 393 | catch (WebException) |
388 | { | 394 | { |
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs index c82f88d..92c808b 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs | |||
@@ -25,6 +25,7 @@ | |||
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 | using System; | 27 | using System; |
28 | using System.Collections; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using libsecondlife; | 31 | using libsecondlife; |
@@ -45,6 +46,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
45 | private Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>(); | 46 | private Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>(); |
46 | private Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>(); | 47 | private Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>(); |
47 | private Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>(); | 48 | private Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>(); |
49 | private Dictionary<LLUUID, List<StoredFriendListUpdate>> StoredFriendListUpdates = new Dictionary<LLUUID, List<StoredFriendListUpdate>>(); | ||
50 | |||
48 | private List<Scene> m_scene = new List<Scene>(); | 51 | private List<Scene> m_scene = new List<Scene>(); |
49 | 52 | ||
50 | #region IRegionModule Members | 53 | #region IRegionModule Members |
@@ -91,6 +94,73 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
91 | public XmlRpcResponse processPresenceUpdate(XmlRpcRequest req) | 94 | public XmlRpcResponse processPresenceUpdate(XmlRpcRequest req) |
92 | { | 95 | { |
93 | m_log.Info("[FRIENDS]: Got Notification about a user! OMG"); | 96 | m_log.Info("[FRIENDS]: Got Notification about a user! OMG"); |
97 | Hashtable requestData = (Hashtable)req.Params[0]; | ||
98 | if (requestData.ContainsKey("agent_id") && requestData.ContainsKey("notify_id") && requestData.ContainsKey("status")) | ||
99 | { | ||
100 | LLUUID notifyAgentId = LLUUID.Zero; | ||
101 | LLUUID notifyAboutAgentId = LLUUID.Zero; | ||
102 | bool notifyOnlineStatus = false; | ||
103 | |||
104 | if ((string)requestData["status"] == "TRUE") | ||
105 | notifyOnlineStatus = true; | ||
106 | |||
107 | Helpers.TryParse((string)requestData["notify_id"], out notifyAgentId); | ||
108 | |||
109 | Helpers.TryParse((string)requestData["agent_id"], out notifyAboutAgentId); | ||
110 | |||
111 | ScenePresence avatar = GetPresenceFromAgentID(notifyAgentId); | ||
112 | if (avatar != null) | ||
113 | { | ||
114 | if (avatar.IsChildAgent) | ||
115 | { | ||
116 | StoredFriendListUpdate sob = new StoredFriendListUpdate(); | ||
117 | sob.OnlineYN = notifyOnlineStatus; | ||
118 | sob.storedAbout = notifyAboutAgentId; | ||
119 | sob.storedFor = notifyAgentId; | ||
120 | lock (StoredFriendListUpdates) | ||
121 | { | ||
122 | if (StoredFriendListUpdates.ContainsKey(notifyAgentId)) | ||
123 | { | ||
124 | StoredFriendListUpdates[notifyAgentId].Add(sob); | ||
125 | } | ||
126 | else | ||
127 | { | ||
128 | List<StoredFriendListUpdate> newitem = new List<StoredFriendListUpdate>(); | ||
129 | newitem.Add(sob); | ||
130 | StoredFriendListUpdates.Add(notifyAgentId, newitem); | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | else | ||
135 | { | ||
136 | if (notifyOnlineStatus) | ||
137 | doFriendListUpdateOnline(notifyAboutAgentId); | ||
138 | else | ||
139 | ClientLoggedOut(notifyAboutAgentId); | ||
140 | } | ||
141 | } | ||
142 | else | ||
143 | { | ||
144 | StoredFriendListUpdate sob = new StoredFriendListUpdate(); | ||
145 | sob.OnlineYN = notifyOnlineStatus; | ||
146 | sob.storedAbout = notifyAboutAgentId; | ||
147 | sob.storedFor = notifyAgentId; | ||
148 | lock (StoredFriendListUpdates) | ||
149 | { | ||
150 | if (StoredFriendListUpdates.ContainsKey(notifyAgentId)) | ||
151 | { | ||
152 | StoredFriendListUpdates[notifyAgentId].Add(sob); | ||
153 | } | ||
154 | else | ||
155 | { | ||
156 | List<StoredFriendListUpdate> newitem = new List<StoredFriendListUpdate>(); | ||
157 | newitem.Add(sob); | ||
158 | StoredFriendListUpdates.Add(notifyAgentId, newitem); | ||
159 | } | ||
160 | } | ||
161 | } | ||
162 | |||
163 | } | ||
94 | return new XmlRpcResponse(); | 164 | return new XmlRpcResponse(); |
95 | } | 165 | } |
96 | 166 | ||
@@ -110,24 +180,30 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
110 | client.OnDenyFriendRequest += OnDenyFriendRequest; | 180 | client.OnDenyFriendRequest += OnDenyFriendRequest; |
111 | client.OnTerminateFriendship += OnTerminateFriendship; | 181 | client.OnTerminateFriendship += OnTerminateFriendship; |
112 | 182 | ||
183 | doFriendListUpdateOnline(client.AgentId); | ||
184 | |||
185 | } | ||
186 | |||
187 | private void doFriendListUpdateOnline(LLUUID AgentId) | ||
188 | { | ||
113 | List<FriendListItem> fl = new List<FriendListItem>(); | 189 | List<FriendListItem> fl = new List<FriendListItem>(); |
114 | 190 | ||
115 | //bool addFLback = false; | 191 | //bool addFLback = false; |
116 | 192 | ||
117 | lock (FriendLists) | 193 | lock (FriendLists) |
118 | { | 194 | { |
119 | if (FriendLists.ContainsKey(client.AgentId)) | 195 | if (FriendLists.ContainsKey(AgentId)) |
120 | { | 196 | { |
121 | fl = FriendLists[client.AgentId]; | 197 | fl = FriendLists[AgentId]; |
122 | } | 198 | } |
123 | else | 199 | else |
124 | { | 200 | { |
125 | fl = m_scene[0].GetFriendList(client.AgentId); | 201 | fl = m_scene[0].GetFriendList(AgentId); |
126 | 202 | ||
127 | //lock (FriendLists) | 203 | //lock (FriendLists) |
128 | //{ | 204 | //{ |
129 | if (!FriendLists.ContainsKey(client.AgentId)) | 205 | if (!FriendLists.ContainsKey(AgentId)) |
130 | FriendLists.Add(client.AgentId, fl); | 206 | FriendLists.Add(AgentId, fl); |
131 | //} | 207 | //} |
132 | } | 208 | } |
133 | } | 209 | } |
@@ -161,11 +237,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
161 | { | 237 | { |
162 | foreach (FriendListItem fli in usrfl) | 238 | foreach (FriendListItem fli in usrfl) |
163 | { | 239 | { |
164 | if (fli.Friend == client.AgentId) | 240 | if (fli.Friend == AgentId) |
165 | { | 241 | { |
166 | fli.onlinestatus = true; | 242 | fli.onlinestatus = true; |
167 | LLUUID[] Agents = new LLUUID[1]; | 243 | LLUUID[] Agents = new LLUUID[1]; |
168 | Agents[0] = client.AgentId; | 244 | Agents[0] = AgentId; |
169 | av.ControllingClient.SendAgentOnline(Agents); | 245 | av.ControllingClient.SendAgentOnline(Agents); |
170 | 246 | ||
171 | } | 247 | } |
@@ -176,8 +252,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
176 | 252 | ||
177 | if (UpdateUsers.Count > 0) | 253 | if (UpdateUsers.Count > 0) |
178 | { | 254 | { |
179 | 255 | ScenePresence avatar = GetPresenceFromAgentID(AgentId); | |
180 | client.SendAgentOnline(UpdateUsers.ToArray()); | 256 | if (avatar != null) |
257 | { | ||
258 | avatar.ControllingClient.SendAgentOnline(UpdateUsers.ToArray()); | ||
259 | } | ||
181 | 260 | ||
182 | } | 261 | } |
183 | } | 262 | } |
@@ -302,6 +381,27 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
302 | { | 381 | { |
303 | m_rootAgents.Add(avatar.UUID, avatar.RegionHandle); | 382 | m_rootAgents.Add(avatar.UUID, avatar.RegionHandle); |
304 | m_log.Info("[FRIEND]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + "."); | 383 | m_log.Info("[FRIEND]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + "."); |
384 | |||
385 | List<StoredFriendListUpdate> updateme = new List<StoredFriendListUpdate>(); | ||
386 | lock (StoredFriendListUpdates) | ||
387 | { | ||
388 | if (StoredFriendListUpdates.ContainsKey(avatar.UUID)) | ||
389 | { | ||
390 | updateme = StoredFriendListUpdates[avatar.UUID]; | ||
391 | StoredFriendListUpdates.Remove(avatar.UUID); | ||
392 | } | ||
393 | } | ||
394 | |||
395 | if (updateme.Count > 0) | ||
396 | { | ||
397 | foreach (StoredFriendListUpdate u in updateme) | ||
398 | { | ||
399 | if (u.OnlineYN) | ||
400 | doFriendListUpdateOnline(u.storedAbout); | ||
401 | else | ||
402 | ClientLoggedOut(u.storedAbout); | ||
403 | } | ||
404 | } | ||
305 | } | 405 | } |
306 | } | 406 | } |
307 | //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString()); | 407 | //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString()); |
@@ -441,8 +541,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
441 | 541 | ||
442 | SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule); | 542 | SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule); |
443 | SceneAgentIn.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, (uint) 1); | 543 | SceneAgentIn.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, (uint) 1); |
444 | m_pendingFriendRequests.Remove(transactionID); | 544 | |
545 | |||
546 | //LLUUID[] Agents = new LLUUID[1]; | ||
547 | //Agents[0] = msg.toAgentID; | ||
548 | //av.ControllingClient.SendAgentOnline(Agents); | ||
445 | 549 | ||
550 | m_pendingFriendRequests.Remove(transactionID); | ||
446 | // TODO: Inform agent that the friend is online | 551 | // TODO: Inform agent that the friend is online |
447 | } | 552 | } |
448 | } | 553 | } |
@@ -498,4 +603,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends | |||
498 | 603 | ||
499 | #endregion | 604 | #endregion |
500 | } | 605 | } |
606 | |||
607 | public struct StoredFriendListUpdate | ||
608 | { | ||
609 | public LLUUID storedFor; | ||
610 | public LLUUID storedAbout; | ||
611 | public bool OnlineYN; | ||
612 | } | ||
501 | } | 613 | } |