aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/HypergridService/HGInstantMessageService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/HypergridService/HGInstantMessageService.cs')
-rw-r--r--OpenSim/Services/HypergridService/HGInstantMessageService.cs51
1 files changed, 47 insertions, 4 deletions
diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
index 4f68e55..66cf4de 100644
--- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs
+++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs
@@ -67,6 +67,10 @@ namespace OpenSim.Services.HypergridService
67 protected static Dictionary<UUID, object> m_UserLocationMap = new Dictionary<UUID, object>(); 67 protected static Dictionary<UUID, object> m_UserLocationMap = new Dictionary<UUID, object>();
68 private static ExpiringCache<UUID, GridRegion> m_RegionCache; 68 private static ExpiringCache<UUID, GridRegion> m_RegionCache;
69 69
70 private static string m_RestURL;
71 private static bool m_ForwardOfflineGroupMessages;
72 private static bool m_InGatekeeper;
73
70 public HGInstantMessageService(IConfigSource config) 74 public HGInstantMessageService(IConfigSource config)
71 : this(config, null) 75 : this(config, null)
72 { 76 {
@@ -81,8 +85,6 @@ namespace OpenSim.Services.HypergridService
81 { 85 {
82 m_Initialized = true; 86 m_Initialized = true;
83 87
84 m_log.DebugFormat("[HG IM SERVICE]: Starting...");
85
86 IConfig serverConfig = config.Configs["HGInstantMessageService"]; 88 IConfig serverConfig = config.Configs["HGInstantMessageService"];
87 if (serverConfig == null) 89 if (serverConfig == null)
88 throw new Exception(String.Format("No section HGInstantMessageService in config file")); 90 throw new Exception(String.Format("No section HGInstantMessageService in config file"));
@@ -90,6 +92,9 @@ namespace OpenSim.Services.HypergridService
90 string gridService = serverConfig.GetString("GridService", String.Empty); 92 string gridService = serverConfig.GetString("GridService", String.Empty);
91 string presenceService = serverConfig.GetString("PresenceService", String.Empty); 93 string presenceService = serverConfig.GetString("PresenceService", String.Empty);
92 string userAgentService = serverConfig.GetString("UserAgentService", String.Empty); 94 string userAgentService = serverConfig.GetString("UserAgentService", String.Empty);
95 m_InGatekeeper = serverConfig.GetBoolean("InGatekeeper", false);
96 m_log.DebugFormat("[HG IM SERVICE]: Starting... InRobust? {0}", m_InGatekeeper);
97
93 98
94 if (gridService == string.Empty || presenceService == string.Empty) 99 if (gridService == string.Empty || presenceService == string.Empty)
95 throw new Exception(String.Format("Incomplete specifications, InstantMessage Service cannot function.")); 100 throw new Exception(String.Format("Incomplete specifications, InstantMessage Service cannot function."));
@@ -101,6 +106,21 @@ namespace OpenSim.Services.HypergridService
101 106
102 m_RegionCache = new ExpiringCache<UUID, GridRegion>(); 107 m_RegionCache = new ExpiringCache<UUID, GridRegion>();
103 108
109 IConfig cnf = config.Configs["Messaging"];
110 if (cnf == null)
111 {
112 return;
113 }
114
115 m_RestURL = cnf.GetString("OfflineMessageURL", string.Empty);
116 if (m_RestURL == string.Empty)
117 {
118 m_log.Error("[HG IM SERVICE]: Offline IMs enabled, but no URL is given");
119 return;
120 }
121
122 m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", false);
123
104 } 124 }
105 } 125 }
106 126
@@ -109,13 +129,21 @@ namespace OpenSim.Services.HypergridService
109 m_log.DebugFormat("[HG IM SERVICE]: Received message from {0} to {1}", im.fromAgentID, im.toAgentID); 129 m_log.DebugFormat("[HG IM SERVICE]: Received message from {0} to {1}", im.fromAgentID, im.toAgentID);
110 UUID toAgentID = new UUID(im.toAgentID); 130 UUID toAgentID = new UUID(im.toAgentID);
111 131
132 bool success = false;
112 if (m_IMSimConnector != null) 133 if (m_IMSimConnector != null)
113 { 134 {
114 //m_log.DebugFormat("[XXX] SendIMToRegion local im connector"); 135 //m_log.DebugFormat("[XXX] SendIMToRegion local im connector");
115 return m_IMSimConnector.SendInstantMessage(im); 136 success = m_IMSimConnector.SendInstantMessage(im);
116 } 137 }
117 else 138 else
118 return TrySendInstantMessage(im, "", true, false); 139 {
140 success = TrySendInstantMessage(im, "", true, false);
141 }
142
143 if (!success && m_InGatekeeper) // we do this only in the Gatekeeper IM service
144 UndeliveredMessage(im);
145
146 return success;
119 } 147 }
120 148
121 public bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner) 149 public bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner)
@@ -129,6 +157,7 @@ namespace OpenSim.Services.HypergridService
129 upd.RegionID = UUID.Zero; 157 upd.RegionID = UUID.Zero;
130 return TrySendInstantMessage(im, upd, true, foreigner); 158 return TrySendInstantMessage(im, upd, true, foreigner);
131 } 159 }
160
132 } 161 }
133 162
134 protected bool TrySendInstantMessage(GridInstantMessage im, object previousLocation, bool firstTime, bool foreigner) 163 protected bool TrySendInstantMessage(GridInstantMessage im, object previousLocation, bool firstTime, bool foreigner)
@@ -313,5 +342,19 @@ namespace OpenSim.Services.HypergridService
313 } 342 }
314 343
315 } 344 }
345
346 private bool UndeliveredMessage(GridInstantMessage im)
347 {
348 if (m_RestURL != string.Empty && (im.offline != 0)
349 && (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages)))
350 {
351 return SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>(
352 "POST", m_RestURL + "/SaveMessage/", im);
353
354 }
355
356 else
357 return false;
358 }
316 } 359 }
317} 360}