aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/MessagingServer/MessageService.cs
diff options
context:
space:
mode:
authorTeravus Ovares2008-06-02 16:16:07 +0000
committerTeravus Ovares2008-06-02 16:16:07 +0000
commit3991908db5b50e764112d30e5750447db67795b5 (patch)
treebc5c47d6c26b87dd04c550ed24d5597e686e7663 /OpenSim/Grid/MessagingServer/MessageService.cs
parentFixed half completed comment in OpenSim.ini.example. (diff)
downloadopensim-SC-3991908db5b50e764112d30e5750447db67795b5.zip
opensim-SC-3991908db5b50e764112d30e5750447db67795b5.tar.gz
opensim-SC-3991908db5b50e764112d30e5750447db67795b5.tar.bz2
opensim-SC-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.
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/MessagingServer/MessageService.cs155
1 files changed, 133 insertions, 22 deletions
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