diff options
author | UbitUmarov | 2015-09-01 14:54:35 +0100 |
---|---|---|
committer | UbitUmarov | 2015-09-01 14:54:35 +0100 |
commit | 371c9dd2af01a2e7422ec901ee1f80757284a78c (patch) | |
tree | 058d2a513cacb12efcce0c0df0ae14ad135dbfe2 /OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | |
parent | remove lixo (diff) | |
parent | dont change camera on crossings (diff) | |
download | opensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.zip opensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.gz opensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.bz2 opensim-SC-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.xz |
bad merge?
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | 113 |
1 files changed, 99 insertions, 14 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 2462ff8..5573c94 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | |||
@@ -50,6 +50,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 51 | ||
52 | private bool m_Enabled = false; | 52 | private bool m_Enabled = false; |
53 | protected string m_MessageKey = String.Empty; | ||
53 | protected List<Scene> m_Scenes = new List<Scene>(); | 54 | protected List<Scene> m_Scenes = new List<Scene>(); |
54 | protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>(); | 55 | protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>(); |
55 | 56 | ||
@@ -69,14 +70,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
69 | public virtual void Initialise(IConfigSource config) | 70 | public virtual void Initialise(IConfigSource config) |
70 | { | 71 | { |
71 | IConfig cnf = config.Configs["Messaging"]; | 72 | IConfig cnf = config.Configs["Messaging"]; |
72 | if (cnf != null && cnf.GetString( | 73 | if (cnf != null) |
73 | "MessageTransferModule", "MessageTransferModule") != | ||
74 | "MessageTransferModule") | ||
75 | { | 74 | { |
76 | m_log.Debug("[MESSAGE TRANSFER]: Disabled by configuration"); | 75 | if (cnf.GetString("MessageTransferModule", |
77 | return; | 76 | "MessageTransferModule") != "MessageTransferModule") |
78 | } | 77 | { |
78 | return; | ||
79 | } | ||
79 | 80 | ||
81 | m_MessageKey = cnf.GetString("MessageKey", String.Empty); | ||
82 | } | ||
83 | m_log.Debug("[MESSAGE TRANSFER]: Module enabled"); | ||
80 | m_Enabled = true; | 84 | m_Enabled = true; |
81 | } | 85 | } |
82 | 86 | ||
@@ -135,6 +139,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
135 | { | 139 | { |
136 | UUID toAgentID = new UUID(im.toAgentID); | 140 | UUID toAgentID = new UUID(im.toAgentID); |
137 | 141 | ||
142 | if (toAgentID == UUID.Zero) | ||
143 | return; | ||
144 | |||
138 | // Try root avatar only first | 145 | // Try root avatar only first |
139 | foreach (Scene scene in m_Scenes) | 146 | foreach (Scene scene in m_Scenes) |
140 | { | 147 | { |
@@ -249,6 +256,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
249 | && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") | 256 | && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") |
250 | && requestData.ContainsKey("binary_bucket")) | 257 | && requestData.ContainsKey("binary_bucket")) |
251 | { | 258 | { |
259 | if (m_MessageKey != String.Empty) | ||
260 | { | ||
261 | XmlRpcResponse error_resp = new XmlRpcResponse(); | ||
262 | Hashtable error_respdata = new Hashtable(); | ||
263 | error_respdata["success"] = "FALSE"; | ||
264 | error_resp.Value = error_respdata; | ||
265 | |||
266 | if (!requestData.Contains("message_key")) | ||
267 | return error_resp; | ||
268 | if (m_MessageKey != (string)requestData["message_key"]) | ||
269 | return error_resp; | ||
270 | } | ||
271 | |||
252 | // Do the easy way of validating the UUIDs | 272 | // Do the easy way of validating the UUIDs |
253 | UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); | 273 | UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); |
254 | UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); | 274 | UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); |
@@ -425,34 +445,89 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
425 | return resp; | 445 | return resp; |
426 | } | 446 | } |
427 | 447 | ||
448 | <<<<<<< HEAD | ||
428 | /// <summary> | 449 | /// <summary> |
429 | /// delegate for sending a grid instant message asynchronously | 450 | /// delegate for sending a grid instant message asynchronously |
430 | /// </summary> | 451 | /// </summary> |
431 | public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result); | 452 | public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result); |
453 | ======= | ||
454 | private delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result); | ||
455 | >>>>>>> avn/ubitvar | ||
432 | 456 | ||
433 | protected virtual void GridInstantMessageCompleted(IAsyncResult iar) | 457 | private class GIM { |
434 | { | 458 | public GridInstantMessage im; |
435 | GridInstantMessageDelegate icon = | 459 | public MessageResultNotification result; |
436 | (GridInstantMessageDelegate)iar.AsyncState; | 460 | }; |
437 | icon.EndInvoke(iar); | ||
438 | } | ||
439 | 461 | ||
462 | private Queue<GIM> pendingInstantMessages = new Queue<GIM>(); | ||
463 | private int numInstantMessageThreads = 0; | ||
440 | 464 | ||
441 | protected virtual void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) | 465 | private void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) |
442 | { | 466 | { |
443 | GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; | 467 | lock (pendingInstantMessages) { |
468 | if (numInstantMessageThreads >= 4) { | ||
469 | GIM gim = new GIM(); | ||
470 | gim.im = im; | ||
471 | gim.result = result; | ||
472 | pendingInstantMessages.Enqueue(gim); | ||
473 | } else { | ||
474 | ++ numInstantMessageThreads; | ||
475 | //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: ++numInstantMessageThreads={0}", numInstantMessageThreads); | ||
476 | GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsyncMain; | ||
477 | d.BeginInvoke(im, result, GridInstantMessageCompleted, d); | ||
478 | } | ||
479 | } | ||
480 | } | ||
444 | 481 | ||
482 | <<<<<<< HEAD | ||
445 | d.BeginInvoke(im, result, GridInstantMessageCompleted, d); | 483 | d.BeginInvoke(im, result, GridInstantMessageCompleted, d); |
484 | ======= | ||
485 | private void GridInstantMessageCompleted(IAsyncResult iar) | ||
486 | { | ||
487 | GridInstantMessageDelegate d = (GridInstantMessageDelegate)iar.AsyncState; | ||
488 | d.EndInvoke(iar); | ||
489 | >>>>>>> avn/ubitvar | ||
446 | } | 490 | } |
447 | 491 | ||
448 | /// <summary> | 492 | /// <summary> |
449 | /// Internal SendGridInstantMessage over XMLRPC method. | 493 | /// Internal SendGridInstantMessage over XMLRPC method. |
450 | /// </summary> | 494 | /// </summary> |
495 | <<<<<<< HEAD | ||
451 | /// <remarks> | 496 | /// <remarks> |
452 | /// This is called from within a dedicated thread. | 497 | /// This is called from within a dedicated thread. |
453 | /// </remarks> | 498 | /// </remarks> |
454 | private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result) | 499 | private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result) |
500 | ======= | ||
501 | /// <param name="prevRegionHandle"> | ||
502 | /// Pass in 0 the first time this method is called. It will be called recursively with the last | ||
503 | /// regionhandle tried | ||
504 | /// </param> | ||
505 | private void SendGridInstantMessageViaXMLRPCAsyncMain(GridInstantMessage im, MessageResultNotification result) | ||
506 | >>>>>>> avn/ubitvar | ||
455 | { | 507 | { |
508 | GIM gim; | ||
509 | do { | ||
510 | try { | ||
511 | SendGridInstantMessageViaXMLRPCAsync(im, result, UUID.Zero); | ||
512 | } catch (Exception e) { | ||
513 | m_log.Error("[SendGridInstantMessageViaXMLRPC]: exception " + e.Message); | ||
514 | } | ||
515 | lock (pendingInstantMessages) { | ||
516 | if (pendingInstantMessages.Count > 0) { | ||
517 | gim = pendingInstantMessages.Dequeue(); | ||
518 | im = gim.im; | ||
519 | result = gim.result; | ||
520 | } else { | ||
521 | gim = null; | ||
522 | -- numInstantMessageThreads; | ||
523 | //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: --numInstantMessageThreads={0}", numInstantMessageThreads); | ||
524 | } | ||
525 | } | ||
526 | } while (gim != null); | ||
527 | } | ||
528 | private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) | ||
529 | { | ||
530 | |||
456 | UUID toAgentID = new UUID(im.toAgentID); | 531 | UUID toAgentID = new UUID(im.toAgentID); |
457 | UUID regionID; | 532 | UUID regionID; |
458 | bool needToLookupAgent; | 533 | bool needToLookupAgent; |
@@ -494,6 +569,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
494 | break; | 569 | break; |
495 | } | 570 | } |
496 | 571 | ||
572 | <<<<<<< HEAD | ||
497 | // Try to send the message to the agent via the retrieved region. | 573 | // Try to send the message to the agent via the retrieved region. |
498 | Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); | 574 | Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); |
499 | msgdata["region_handle"] = 0; | 575 | msgdata["region_handle"] = 0; |
@@ -501,6 +577,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
501 | 577 | ||
502 | // If the message delivery was successful, then cache the entry. | 578 | // If the message delivery was successful, then cache the entry. |
503 | if (imresult) | 579 | if (imresult) |
580 | ======= | ||
581 | if (upd != null) | ||
582 | { | ||
583 | GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(UUID.Zero, | ||
584 | upd.RegionID); | ||
585 | if (reginfo != null) | ||
586 | >>>>>>> avn/ubitvar | ||
504 | { | 587 | { |
505 | lock (m_UserRegionMap) | 588 | lock (m_UserRegionMap) |
506 | { | 589 | { |
@@ -622,6 +705,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
622 | gim["position_z"] = msg.Position.Z.ToString(); | 705 | gim["position_z"] = msg.Position.Z.ToString(); |
623 | gim["region_id"] = new UUID(msg.RegionID).ToString(); | 706 | gim["region_id"] = new UUID(msg.RegionID).ToString(); |
624 | gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); | 707 | gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); |
708 | if (m_MessageKey != String.Empty) | ||
709 | gim["message_key"] = m_MessageKey; | ||
625 | return gim; | 710 | return gim; |
626 | } | 711 | } |
627 | 712 | ||