Adding region up/down notifications to the PresenceModule. Messaging

Server portion remains to be implemented
0.6.1-post-fixes
Melanie Thielker 2008-11-22 20:29:00 +00:00
parent 84db1e1290
commit bf885b2035
1 changed files with 42 additions and 0 deletions

View File

@ -46,6 +46,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private bool m_Enabled = false;
private bool m_Gridmode = false; private bool m_Gridmode = false;
private List<Scene> m_Scenes = new List<Scene>(); private List<Scene> m_Scenes = new List<Scene>();
@ -64,12 +65,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
if (cnf != null) if (cnf != null)
m_Gridmode = cnf.GetBoolean("gridmode", false); m_Gridmode = cnf.GetBoolean("gridmode", false);
m_Enabled = true;
lock (m_Scenes) lock (m_Scenes)
{ {
if (m_Scenes.Count == 0) if (m_Scenes.Count == 0)
{ {
} }
if (m_Gridmode)
NotifyMessageServerOfStartup(scene);
scene.RegisterModuleInterface<IPresenceModule>(this); scene.RegisterModuleInterface<IPresenceModule>(this);
m_Scenes.Add(scene); m_Scenes.Add(scene);
} }
@ -81,6 +86,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
public void Close() public void Close()
{ {
if (!m_Gridmode || !m_Enabled)
return;
foreach (Scene scene in m_Scenes)
NotifyMessageServerOfShutdown(scene);
} }
public string Name public string Name
@ -96,5 +106,37 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
public void RequestBulkPresenceData(UUID[] users) public void RequestBulkPresenceData(UUID[] users)
{ {
} }
private void NotifyMessageServerOfStartup(Scene scene)
{
Hashtable xmlrpcdata = new Hashtable();
xmlrpcdata["RegionName"] = scene.RegionInfo.RegionName;
ArrayList SendParams = new ArrayList();
SendParams.Add(xmlrpcdata);
XmlRpcRequest UpRequest = new XmlRpcRequest("region_startup", SendParams);
XmlRpcResponse resp = UpRequest.Send(scene.CommsManager.NetworkServersInfo.MessagingURL, 5000);
Hashtable responseData = (Hashtable)resp.Value;
if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE")
{
m_log.ErrorFormat("[PRESENCE] Failed to notify message server of region startup for region {0}", scene.RegionInfo.RegionName);
}
}
private void NotifyMessageServerOfShutdown(Scene scene)
{
Hashtable xmlrpcdata = new Hashtable();
xmlrpcdata["RegionName"] = scene.RegionInfo.RegionName;
ArrayList SendParams = new ArrayList();
SendParams.Add(xmlrpcdata);
XmlRpcRequest DownRequest = new XmlRpcRequest("region_shutdown", SendParams);
XmlRpcResponse resp = DownRequest.Send(scene.CommsManager.NetworkServersInfo.MessagingURL, 5000);
Hashtable responseData = (Hashtable)resp.Value;
if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE")
{
m_log.ErrorFormat("[PRESENCE] Failed to notify message server of region shutdown for region {0}", scene.RegionInfo.RegionName);
}
}
} }
} }