public string ConsoleSimulatorsRequest(Environment env)
        {
            m_log.Debug("[Wifi]: ConsoleSimulatorsRequest");
            string result = string.Empty;

            SessionInfo sinfo;
            if (TryGetSessionInfo(env.Request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                // Retrieve addresses of simulators (and the regions running on them)
                List<GridRegion> allRegions = m_GridService.GetRegionsByName(UUID.Zero, "", 200);
                List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(UUID.Zero);
                IEnumerable<GridRegion> regions = allRegions.Except(hyperlinks);

                NameValueCollection simulators = new NameValueCollection();
                if (regions != null)
                {
                    foreach (GridRegion region in regions)
                    {
                        string address = region.ExternalHostName + ':' + region.HttpPort;
                        simulators.Add(address, region.RegionName);
                    }
                }

                // Create an XML document with the result data
                XmlDocument xmldoc = new XmlDocument();
                XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
                xmldoc.AppendChild(xmlnode);

                XmlElement rootElement = xmldoc.CreateElement("Wifi");
                xmldoc.AppendChild(rootElement);

                XmlElement simulatorsElement = xmldoc.CreateElement("Simulators");
                rootElement.AppendChild(simulatorsElement);

                foreach (string address in simulators.AllKeys)
                {
                    XmlElement simElement = xmldoc.CreateElement("Simulator");
                    simElement.SetAttribute("HostAddress", address);
                    simulatorsElement.AppendChild(simElement);

                    foreach (string regionName in simulators.GetValues(address))
                    {
                        XmlElement regionElement = xmldoc.CreateElement("Region");
                        simElement.AppendChild(regionElement);

                        XmlElement nameElement = xmldoc.CreateElement("Name");
                        nameElement.AppendChild(xmldoc.CreateTextNode(regionName));
                        regionElement.AppendChild(nameElement);
                    }
                }

                result = xmldoc.InnerXml;
            }
            return result;
        }
        public string ConsoleHeartbeat(Environment env)
        {
            m_log.DebugFormat("[Wifi]: ConsoleHeartbeat");
            SessionInfo sinfo;
            if (TryGetSessionInfo(env.Request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                // Reset session timer
                m_Sessions.Update(sinfo.Sid, sinfo, m_WebApp.SessionTimeout);
            }

            return string.Empty;
        }
        public string ConsoleRequest(Environment env)
        {
            m_log.DebugFormat("[Wifi]: ConsoleRequest");
            SessionInfo sinfo;
            if (TryGetSessionInfo(env.Request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;
                env.Flags = Flags.IsLoggedIn | Flags.IsAdmin;
                env.State = State.Console;
                return PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
            }

            return m_WebApp.ReadFile(env, "index.html");
        }
 public void NotifyWithRedirect(Environment env, string message, string buttonText,
     int redirectSeconds, string redirectUrl, ServiceCall followUp)
 {
     env.Data = new List<object>();
     env.Data.Add(new Notification(message, buttonText));
     env.State = State.Notification;
     SessionInfo sinfo = env.Session;
     if (sinfo.Sid != null && m_Sessions.Contains(sinfo.Sid))
     {
         sinfo.Notify.FollowUp = followUp;
         sinfo.Notify.RedirectUrl = redirectUrl; // used in WifiScriptFace.GetRefresh()
         sinfo.Notify.RedirectDelay = redirectSeconds;
         m_Sessions.Update(sinfo.Sid, sinfo, m_WebApp.SessionTimeout);
         env.Session = sinfo;
     }
 }
        public string NotifyRequest(Environment env)
        {
            m_log.Debug("[Wifi]: NotifyRequest");

            SessionInfo sinfo;
            if (TryGetSessionInfo(env.Request, out sinfo))
            {
                env.Session = sinfo;
                env.Flags = Flags.IsLoggedIn;
                if (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel)
                    env.Flags |= Flags.IsAdmin;

                return sinfo.Notify.FollowUp(env);
            }
            m_log.Debug("[Wifi]: No session info with NotifyRequest");
            return m_WebApp.ReadFile(env, "index.html");
        }
 public void NotifyWithoutButton(Environment env, string message)
 {
     Notify(env, message, string.Empty, null);
 }
 public void NotifyOK(Environment env, string message, ServiceCall followUp)
 {
     Notify(env, message, _("OK", env), followUp);
 }
 public void Notify(Environment env, string message, string buttonText, ServiceCall followUp)
 {
     NotifyWithRedirect(env, message, buttonText, -1, string.Empty, followUp);
 }