diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | 78 |
1 files changed, 31 insertions, 47 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index ad050a1..5d20e63 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | |||
@@ -471,7 +471,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
471 | if (m_UserRegionMap.ContainsKey(toAgentID)) | 471 | if (m_UserRegionMap.ContainsKey(toAgentID)) |
472 | { | 472 | { |
473 | upd = new PresenceInfo(); | 473 | upd = new PresenceInfo(); |
474 | upd.Online = true; | ||
475 | upd.RegionID = m_UserRegionMap[toAgentID]; | 474 | upd.RegionID = m_UserRegionMap[toAgentID]; |
476 | 475 | ||
477 | // We need to compare the current regionhandle with the previous region handle | 476 | // We need to compare the current regionhandle with the previous region handle |
@@ -493,15 +492,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
493 | { | 492 | { |
494 | // Non-cached user agent lookup. | 493 | // Non-cached user agent lookup. |
495 | PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); | 494 | PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); |
496 | if (presences != null) | 495 | if (presences != null && presences.Length > 0) |
497 | { | 496 | upd = presences[0]; |
498 | foreach (PresenceInfo p in presences) | ||
499 | if (p.Online) | ||
500 | { | ||
501 | upd = presences[0]; | ||
502 | break; | ||
503 | } | ||
504 | } | ||
505 | 497 | ||
506 | if (upd != null) | 498 | if (upd != null) |
507 | { | 499 | { |
@@ -525,61 +517,53 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
525 | 517 | ||
526 | if (upd != null) | 518 | if (upd != null) |
527 | { | 519 | { |
528 | if (upd.Online) | 520 | GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, |
521 | upd.RegionID); | ||
522 | if (reginfo != null) | ||
529 | { | 523 | { |
530 | GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, | 524 | Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); |
531 | upd.RegionID); | 525 | // Not actually used anymore, left in for compatibility |
532 | if (reginfo != null) | 526 | // Remove at next interface change |
527 | // | ||
528 | msgdata["region_handle"] = 0; | ||
529 | bool imresult = doIMSending(reginfo, msgdata); | ||
530 | if (imresult) | ||
533 | { | 531 | { |
534 | Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); | 532 | // IM delivery successful, so store the Agent's location in our local cache. |
535 | // Not actually used anymore, left in for compatibility | 533 | lock (m_UserRegionMap) |
536 | // Remove at next interface change | ||
537 | // | ||
538 | msgdata["region_handle"] = 0; | ||
539 | bool imresult = doIMSending(reginfo, msgdata); | ||
540 | if (imresult) | ||
541 | { | 534 | { |
542 | // IM delivery successful, so store the Agent's location in our local cache. | 535 | if (m_UserRegionMap.ContainsKey(toAgentID)) |
543 | lock (m_UserRegionMap) | ||
544 | { | 536 | { |
545 | if (m_UserRegionMap.ContainsKey(toAgentID)) | 537 | m_UserRegionMap[toAgentID] = upd.RegionID; |
546 | { | 538 | } |
547 | m_UserRegionMap[toAgentID] = upd.RegionID; | 539 | else |
548 | } | 540 | { |
549 | else | 541 | m_UserRegionMap.Add(toAgentID, upd.RegionID); |
550 | { | ||
551 | m_UserRegionMap.Add(toAgentID, upd.RegionID); | ||
552 | } | ||
553 | } | 542 | } |
554 | result(true); | ||
555 | } | ||
556 | else | ||
557 | { | ||
558 | // try again, but lookup user this time. | ||
559 | // Warning, this must call the Async version | ||
560 | // of this method or we'll be making thousands of threads | ||
561 | // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync | ||
562 | // The version that spawns the thread is SendGridInstantMessageViaXMLRPC | ||
563 | |||
564 | // This is recursive!!!!! | ||
565 | SendGridInstantMessageViaXMLRPCAsync(im, result, | ||
566 | upd.RegionID); | ||
567 | } | 543 | } |
544 | result(true); | ||
568 | } | 545 | } |
569 | else | 546 | else |
570 | { | 547 | { |
571 | m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); | 548 | // try again, but lookup user this time. |
572 | HandleUndeliveredMessage(im, result); | 549 | // Warning, this must call the Async version |
550 | // of this method or we'll be making thousands of threads | ||
551 | // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync | ||
552 | // The version that spawns the thread is SendGridInstantMessageViaXMLRPC | ||
553 | |||
554 | // This is recursive!!!!! | ||
555 | SendGridInstantMessageViaXMLRPCAsync(im, result, | ||
556 | upd.RegionID); | ||
573 | } | 557 | } |
574 | } | 558 | } |
575 | else | 559 | else |
576 | { | 560 | { |
561 | m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); | ||
577 | HandleUndeliveredMessage(im, result); | 562 | HandleUndeliveredMessage(im, result); |
578 | } | 563 | } |
579 | } | 564 | } |
580 | else | 565 | else |
581 | { | 566 | { |
582 | m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find user {0}", toAgentID); | ||
583 | HandleUndeliveredMessage(im, result); | 567 | HandleUndeliveredMessage(im, result); |
584 | } | 568 | } |
585 | } | 569 | } |