aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/InstantMessage
diff options
context:
space:
mode:
authorDiva Canto2010-01-07 15:53:55 -0800
committerDiva Canto2010-01-07 15:53:55 -0800
commitf11a97f12d328af8bb39b92fec5cb5780983b66a (patch)
tree00f96f853b91e105786b416dd18f2c76e56fd1fd /OpenSim/Region/CoreModules/Avatar/InstantMessage
parentMerge branch 'master' into presence-refactor (diff)
downloadopensim-SC_OLD-f11a97f12d328af8bb39b92fec5cb5780983b66a.zip
opensim-SC_OLD-f11a97f12d328af8bb39b92fec5cb5780983b66a.tar.gz
opensim-SC_OLD-f11a97f12d328af8bb39b92fec5cb5780983b66a.tar.bz2
opensim-SC_OLD-f11a97f12d328af8bb39b92fec5cb5780983b66a.tar.xz
* Finished SimulationServiceConnector
* Started rerouting calls to UserService. * Compiles. May run.
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/InstantMessage')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs60
1 files changed, 40 insertions, 20 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 2d4b421..c0d3f31 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -37,6 +37,8 @@ using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion; 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
41using OpenSim.Services.Interfaces;
40 42
41namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 43namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
42{ 44{
@@ -46,10 +48,21 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
46 48
47 private bool m_Enabled = false; 49 private bool m_Enabled = false;
48 protected List<Scene> m_Scenes = new List<Scene>(); 50 protected List<Scene> m_Scenes = new List<Scene>();
49 protected Dictionary<UUID, ulong> m_UserRegionMap = new Dictionary<UUID, ulong>(); 51 protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>();
50 52
51 public event UndeliveredMessage OnUndeliveredMessage; 53 public event UndeliveredMessage OnUndeliveredMessage;
52 54
55 private IPresenceService m_PresenceService;
56 protected IPresenceService PresenceService
57 {
58 get
59 {
60 if (m_PresenceService == null)
61 m_PresenceService = m_Scenes[0].RequestModuleInterface<IPresenceService>();
62 return m_PresenceService;
63 }
64 }
65
53 public virtual void Initialise(IConfigSource config) 66 public virtual void Initialise(IConfigSource config)
54 { 67 {
55 IConfig cnf = config.Configs["Messaging"]; 68 IConfig cnf = config.Configs["Messaging"];
@@ -416,7 +429,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
416 /// <summary> 429 /// <summary>
417 /// delegate for sending a grid instant message asynchronously 430 /// delegate for sending a grid instant message asynchronously
418 /// </summary> 431 /// </summary>
419 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle); 432 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID);
420 433
421 protected virtual void GridInstantMessageCompleted(IAsyncResult iar) 434 protected virtual void GridInstantMessageCompleted(IAsyncResult iar)
422 { 435 {
@@ -430,7 +443,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
430 { 443 {
431 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; 444 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync;
432 445
433 d.BeginInvoke(im, result, 0, GridInstantMessageCompleted, d); 446 d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d);
434 } 447 }
435 448
436 /// <summary> 449 /// <summary>
@@ -445,11 +458,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
445 /// Pass in 0 the first time this method is called. It will be called recursively with the last 458 /// Pass in 0 the first time this method is called. It will be called recursively with the last
446 /// regionhandle tried 459 /// regionhandle tried
447 /// </param> 460 /// </param>
448 protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle) 461 protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
449 { 462 {
450 UUID toAgentID = new UUID(im.toAgentID); 463 UUID toAgentID = new UUID(im.toAgentID);
451 464
452 UserAgentData upd = null; 465 PresenceInfo upd = null;
453 466
454 bool lookupAgent = false; 467 bool lookupAgent = false;
455 468
@@ -457,13 +470,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
457 { 470 {
458 if (m_UserRegionMap.ContainsKey(toAgentID)) 471 if (m_UserRegionMap.ContainsKey(toAgentID))
459 { 472 {
460 upd = new UserAgentData(); 473 upd = new PresenceInfo();
461 upd.AgentOnline = true; 474 upd.Online = true;
462 upd.Handle = m_UserRegionMap[toAgentID]; 475 upd.RegionID = m_UserRegionMap[toAgentID];
463 476
464 // We need to compare the current regionhandle with the previous region handle 477 // We need to compare the current regionhandle with the previous region handle
465 // or the recursive loop will never end because it will never try to lookup the agent again 478 // or the recursive loop will never end because it will never try to lookup the agent again
466 if (prevRegionHandle == upd.Handle) 479 if (prevRegionID == upd.RegionID)
467 { 480 {
468 lookupAgent = true; 481 lookupAgent = true;
469 } 482 }
@@ -479,14 +492,23 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
479 if (lookupAgent) 492 if (lookupAgent)
480 { 493 {
481 // Non-cached user agent lookup. 494 // Non-cached user agent lookup.
482 upd = m_Scenes[0].CommsManager.UserService.GetAgentByUUID(toAgentID); 495 PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() });
496 if (presences != null)
497 {
498 foreach (PresenceInfo p in presences)
499 if (p.Online)
500 {
501 upd = presences[0];
502 break;
503 }
504 }
483 505
484 if (upd != null) 506 if (upd != null)
485 { 507 {
486 // check if we've tried this before.. 508 // check if we've tried this before..
487 // This is one way to end the recursive loop 509 // This is one way to end the recursive loop
488 // 510 //
489 if (upd.Handle == prevRegionHandle) 511 if (upd.RegionID == prevRegionID)
490 { 512 {
491 m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); 513 m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
492 HandleUndeliveredMessage(im, result); 514 HandleUndeliveredMessage(im, result);
@@ -503,12 +525,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
503 525
504 if (upd != null) 526 if (upd != null)
505 { 527 {
506 if (upd.AgentOnline) 528 if (upd.Online)
507 { 529 {
508 uint x = 0, y = 0; 530 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID,
509 Utils.LongToUInts(upd.Handle, out x, out y); 531 upd.RegionID);
510 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByPosition(m_Scenes[0].RegionInfo.ScopeID,
511 (int)x, (int)y);
512 if (reginfo != null) 532 if (reginfo != null)
513 { 533 {
514 Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); 534 Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im);
@@ -524,11 +544,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
524 { 544 {
525 if (m_UserRegionMap.ContainsKey(toAgentID)) 545 if (m_UserRegionMap.ContainsKey(toAgentID))
526 { 546 {
527 m_UserRegionMap[toAgentID] = upd.Handle; 547 m_UserRegionMap[toAgentID] = upd.RegionID;
528 } 548 }
529 else 549 else
530 { 550 {
531 m_UserRegionMap.Add(toAgentID, upd.Handle); 551 m_UserRegionMap.Add(toAgentID, upd.RegionID);
532 } 552 }
533 } 553 }
534 result(true); 554 result(true);
@@ -543,12 +563,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
543 563
544 // This is recursive!!!!! 564 // This is recursive!!!!!
545 SendGridInstantMessageViaXMLRPCAsync(im, result, 565 SendGridInstantMessageViaXMLRPCAsync(im, result,
546 upd.Handle); 566 upd.RegionID);
547 } 567 }
548 } 568 }
549 else 569 else
550 { 570 {
551 m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.Handle); 571 m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID);
552 HandleUndeliveredMessage(im, result); 572 HandleUndeliveredMessage(im, result);
553 } 573 }
554 } 574 }