From ac2fcbe224d4877dccc4d73e9c58771e40a4ae1c Mon Sep 17 00:00:00 2001 From: CasperW Date: Thu, 26 Nov 2009 15:17:44 +0100 Subject: Improvements to rAdmin admin_shutdown and admin_restart. Both methods can now accept a parameter of noticetype = dialog in order to display a blue persistant dropdown instead of a short notice. Added an optional and configurable delay to the restart method, defaulting at 30 seconds as before. Both methods can also accept a noticetype = none dialog in order to act silently. --- .../RemoteController/RemoteAdminPlugin.cs | 74 +++++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) (limited to 'OpenSim/ApplicationPlugins') diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 3bc557d..325816d 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -213,9 +213,59 @@ namespace OpenSim.ApplicationPlugins.RemoteController if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene)) throw new Exception("region not found"); + int timeout = 30000; + string message; + + if (requestData.ContainsKey("restart") + && ((string)requestData["restart"] == "delayed") + && requestData.ContainsKey("milliseconds")) + { + timeout = Int32.Parse(requestData["milliseconds"].ToString()); + + if (timeout < 15000) + { + //It must be at least 15 seconds or we'll cancel the reboot request + timeout = 15000; + } + + message + = "Region is restarting in " + ((int)(timeout / 1000)).ToString() + + " second(s). Please save what you are doing and log out."; + } + else + { + message = "Region is restarting in 30 second(s). Please save what you are doing and log out."; + } + + if (requestData.ContainsKey("noticetype") + && ((string)requestData["noticetype"] == "dialog")) + { + m_app.SceneManager.ForEachScene( + delegate(Scene scene) + { + IDialogModule dialogModule = scene.RequestModuleInterface(); + if (dialogModule != null) + dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); + }); + } + else + { + if (!requestData.ContainsKey("noticetype") + || ((string)requestData["noticetype"] != "none")) + { + m_app.SceneManager.ForEachScene( + delegate(Scene scene) + { + IDialogModule dialogModule = scene.RequestModuleInterface(); + if (dialogModule != null) + dialogModule.SendGeneralAlert(message); + }); + } + } + responseData["rebooting"] = true; response.Value = responseData; - rebootedScene.Restart(30); + rebootedScene.Restart(timeout / 1000,false); } catch (Exception e) { @@ -419,13 +469,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController message = "Region is going down now."; } - m_app.SceneManager.ForEachScene( + if (requestData.ContainsKey("noticetype") + && ((string) requestData["noticetype"] == "dialog")) + { + m_app.SceneManager.ForEachScene( delegate(Scene scene) { IDialogModule dialogModule = scene.RequestModuleInterface(); if (dialogModule != null) + dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message); + }); + } + else + { + if (!requestData.ContainsKey("noticetype") + || ((string)requestData["noticetype"] != "none")) + { + m_app.SceneManager.ForEachScene( + delegate(Scene scene) + { + IDialogModule dialogModule = scene.RequestModuleInterface(); + if (dialogModule != null) dialogModule.SendGeneralAlert(message); }); + } + } + + // Perform shutdown System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing -- cgit v1.1