* refactor: move alert commands from Scene to DialogModule
parent
a46c9b0eea
commit
d307109e1a
|
@ -182,7 +182,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||||
XmlRpcResponse response = new XmlRpcResponse();
|
XmlRpcResponse response = new XmlRpcResponse();
|
||||||
Hashtable responseData = new Hashtable();
|
Hashtable responseData = new Hashtable();
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
Hashtable requestData = (Hashtable) request.Params[0];
|
Hashtable requestData = (Hashtable) request.Params[0];
|
||||||
|
|
||||||
checkStringParameters(request, new string[] { "password", "message" });
|
checkStringParameters(request, new string[] { "password", "message" });
|
||||||
|
@ -197,8 +198,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||||
responseData["accepted"] = "true";
|
responseData["accepted"] = "true";
|
||||||
responseData["success"] = "true";
|
responseData["success"] = "true";
|
||||||
response.Value = responseData;
|
response.Value = responseData;
|
||||||
|
|
||||||
m_app.SceneManager.SendGeneralMessage(message);
|
m_app.SceneManager.ForEachScene(
|
||||||
|
delegate(Scene scene)
|
||||||
|
{
|
||||||
|
IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
|
||||||
|
if (dialogModule != null)
|
||||||
|
dialogModule.SendGeneralAlert(message);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
@ -283,19 +290,30 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||||
response.Value = responseData;
|
response.Value = responseData;
|
||||||
|
|
||||||
int timeout = 2000;
|
int timeout = 2000;
|
||||||
|
string message;
|
||||||
|
|
||||||
if (requestData.ContainsKey("shutdown") &&
|
if (requestData.ContainsKey("shutdown")
|
||||||
((string) requestData["shutdown"] == "delayed") &&
|
&& ((string) requestData["shutdown"] == "delayed")
|
||||||
requestData.ContainsKey("milliseconds"))
|
&& requestData.ContainsKey("milliseconds"))
|
||||||
{
|
{
|
||||||
timeout = (Int32) requestData["milliseconds"];
|
timeout = (Int32) requestData["milliseconds"];
|
||||||
m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int) (timeout/1000)).ToString() +
|
|
||||||
" second(s). Please save what you are doing and log out.");
|
message
|
||||||
|
= "Region is going down in " + ((int) (timeout/1000)).ToString()
|
||||||
|
+ " second(s). Please save what you are doing and log out.";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_app.SceneManager.SendGeneralMessage("Region is going down now.");
|
message = "Region is going down now.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_app.SceneManager.ForEachScene(
|
||||||
|
delegate(Scene scene)
|
||||||
|
{
|
||||||
|
IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
|
||||||
|
if (dialogModule != null)
|
||||||
|
dialogModule.SendGeneralAlert(message);
|
||||||
|
});
|
||||||
|
|
||||||
// Perform shutdown
|
// Perform shutdown
|
||||||
Timer shutdownTimer = new Timer(timeout); // Wait before firing
|
Timer shutdownTimer = new Timer(timeout); // Wait before firing
|
||||||
|
|
|
@ -177,14 +177,6 @@ namespace OpenSim
|
||||||
"show queues",
|
"show queues",
|
||||||
"Show queue data", HandleShow);
|
"Show queue data", HandleShow);
|
||||||
|
|
||||||
m_console.Commands.AddCommand("region", false, "alert",
|
|
||||||
"alert <first> <last> <message>",
|
|
||||||
"Send an alert to a user", RunCommand);
|
|
||||||
|
|
||||||
m_console.Commands.AddCommand("region", false, "alert general",
|
|
||||||
"alert general <message>",
|
|
||||||
"Send an alert everyone", RunCommand);
|
|
||||||
|
|
||||||
m_console.Commands.AddCommand("region", false, "backup",
|
m_console.Commands.AddCommand("region", false, "backup",
|
||||||
"backup",
|
"backup",
|
||||||
"Persist objects to the database now", RunCommand);
|
"Persist objects to the database now", RunCommand);
|
||||||
|
@ -547,7 +539,6 @@ namespace OpenSim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Runs commands issued by the server console from the operator
|
/// Runs commands issued by the server console from the operator
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -577,10 +568,6 @@ namespace OpenSim
|
||||||
m_sceneManager.BackupCurrentScene();
|
m_sceneManager.BackupCurrentScene();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "alert":
|
|
||||||
m_sceneManager.HandleAlertCommandOnCurrentScene(cmdparams);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "remove-region":
|
case "remove-region":
|
||||||
string regRemoveName = CombineParams(cmdparams, 0);
|
string regRemoveName = CombineParams(cmdparams, 0);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
using log4net;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
@ -36,7 +38,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
|
||||||
{
|
{
|
||||||
public class DialogModule : IRegionModule, IDialogModule
|
public class DialogModule : IRegionModule, IDialogModule
|
||||||
{
|
{
|
||||||
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
protected Scene m_scene;
|
protected Scene m_scene;
|
||||||
|
|
||||||
|
@ -44,6 +46,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
|
||||||
{
|
{
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
m_scene.RegisterModuleInterface<IDialogModule>(this);
|
m_scene.RegisterModuleInterface<IDialogModule>(this);
|
||||||
|
|
||||||
|
m_scene.AddCommand(
|
||||||
|
this, "alert", "alert <first> <last> <message>", "Send an alert to a user", HandleAlertConsoleCommand);
|
||||||
|
|
||||||
|
m_scene.AddCommand(
|
||||||
|
this, "alert general", "alert general <message>", "Send an alert to everyone", HandleAlertConsoleCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PostInitialise() {}
|
public void PostInitialise() {}
|
||||||
|
@ -137,5 +145,47 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
|
||||||
presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message);
|
presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handle an alert command from the console.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="module"></param>
|
||||||
|
/// <param name="cmdparams"></param>
|
||||||
|
public void HandleAlertConsoleCommand(string module, string[] cmdparams)
|
||||||
|
{
|
||||||
|
if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cmdparams[1] == "general")
|
||||||
|
{
|
||||||
|
string message = CombineParams(cmdparams, 2);
|
||||||
|
|
||||||
|
m_log.InfoFormat(
|
||||||
|
"[DIALOG]: Sending general alert in region {0} with message {1}", m_scene.RegionInfo.RegionName, message);
|
||||||
|
SendGeneralAlert(message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string firstName = cmdparams[1];
|
||||||
|
string lastName = cmdparams[2];
|
||||||
|
string message = CombineParams(cmdparams, 3);
|
||||||
|
|
||||||
|
m_log.InfoFormat(
|
||||||
|
"[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}",
|
||||||
|
m_scene.RegionInfo.RegionName, firstName, lastName, message);
|
||||||
|
SendAlertToUser(firstName, lastName, message, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string CombineParams(string[] commandParams, int pos)
|
||||||
|
{
|
||||||
|
string result = string.Empty;
|
||||||
|
for (int i = pos; i < commandParams.Length; i++)
|
||||||
|
{
|
||||||
|
result += commandParams[i] + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2213,7 +2213,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
lock (av)
|
lock (av)
|
||||||
{
|
{
|
||||||
|
|
||||||
for (int i = 0; i < regionslst.Count; i++)
|
for (int i = 0; i < regionslst.Count; i++)
|
||||||
{
|
{
|
||||||
av.KnownChildRegionHandles.Remove(regionslst[i]);
|
av.KnownChildRegionHandles.Remove(regionslst[i]);
|
||||||
|
@ -2902,35 +2901,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Handle an alert command from the console.
|
|
||||||
/// FIXME: Command parsing code really shouldn't be in this core Scene class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="commandParams"></param>
|
|
||||||
public void HandleAlertCommand(string[] commandParams)
|
|
||||||
{
|
|
||||||
if (commandParams[0] == "general")
|
|
||||||
{
|
|
||||||
string message = CombineParams(commandParams, 1);
|
|
||||||
m_dialogModule.SendGeneralAlert(message);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string message = CombineParams(commandParams, 2);
|
|
||||||
m_dialogModule.SendAlertToUser(commandParams[0], commandParams[1], message, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private string CombineParams(string[] commandParams, int pos)
|
|
||||||
{
|
|
||||||
string result = String.Empty;
|
|
||||||
for (int i = pos; i < commandParams.Length; i++)
|
|
||||||
{
|
|
||||||
result += commandParams[i] + " ";
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -296,16 +296,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); });
|
ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleAlertCommandOnCurrentScene(string[] cmdparams)
|
|
||||||
{
|
|
||||||
ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); });
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SendGeneralMessage(string msg)
|
|
||||||
{
|
|
||||||
ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(new string[] { "general", msg }); });
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TrySetCurrentScene(string regionName)
|
public bool TrySetCurrentScene(string regionName)
|
||||||
{
|
{
|
||||||
if ((String.Compare(regionName, "root") == 0)
|
if ((String.Compare(regionName, "root") == 0)
|
||||||
|
|
Loading…
Reference in New Issue