aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs136
1 files changed, 0 insertions, 136 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs
deleted file mode 100644
index 468faea..0000000
--- a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs
+++ /dev/null
@@ -1,136 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Xml.Serialization;
31using OpenMetaverse;
32using OpenSim.Framework.Servers;
33using OpenSim.Framework.Servers.HttpServer;
34using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes;
36
37namespace OpenSim.ApplicationPlugins.Rest.Regions
38{
39 public partial class RestRegionPlugin : RestPlugin
40 {
41 #region GET methods
42 public string GetRegionInfoHandler(string request, string path, string param,
43 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
44 {
45 // foreach (string h in httpRequest.Headers.AllKeys)
46 // foreach (string v in httpRequest.Headers.GetValues(h))
47 // m_log.DebugFormat("{0} IsGod: {1} -> {2}", MsgID, h, v);
48
49 MsgID = RequestID;
50 m_log.DebugFormat("{0} GET path {1} param {2}", MsgID, path, param);
51
52 try
53 {
54 // param empty: regions list
55 // if (String.IsNullOrEmpty(param))
56 return GetRegionInfoHandlerRegions(httpResponse);
57
58 // // param not empty: specific region
59 // return GetRegionInfoHandlerRegion(httpResponse, param);
60 }
61 catch (Exception e)
62 {
63 return Failure(httpResponse, OSHttpStatusCode.ServerErrorInternalError, "GET", e);
64 }
65 }
66
67 public string GetRegionInfoHandlerRegions(IOSHttpResponse httpResponse)
68 {
69 RestXmlWriter rxw = new RestXmlWriter(new StringWriter());
70
71 // regions info
72 rxw.WriteStartElement(String.Empty, "regions", String.Empty);
73 {
74 // regions info: number of regions
75 rxw.WriteStartAttribute(String.Empty, "number", String.Empty);
76 rxw.WriteValue(App.SceneManager.Scenes.Count);
77 rxw.WriteEndAttribute();
78
79 // regions info: max number of regions
80 rxw.WriteStartAttribute(String.Empty, "max", String.Empty);
81 if (App.ConfigSource.Source.Configs["RemoteAdmin"] != null)
82 {
83 rxw.WriteValue(App.ConfigSource.Source.Configs["RemoteAdmin"].GetInt("region_limit", -1));
84 }
85 else
86 {
87 rxw.WriteValue(-1);
88 }
89 rxw.WriteEndAttribute();
90
91 // regions info: region
92 foreach (Scene s in App.SceneManager.Scenes)
93 {
94 rxw.WriteStartElement(String.Empty, "region", String.Empty);
95
96 rxw.WriteStartAttribute(String.Empty, "uuid", String.Empty);
97 rxw.WriteString(s.RegionInfo.RegionID.ToString());
98 rxw.WriteEndAttribute();
99
100 rxw.WriteStartAttribute(String.Empty, "name", String.Empty);
101 rxw.WriteString(s.RegionInfo.RegionName);
102 rxw.WriteEndAttribute();
103
104 rxw.WriteStartAttribute(String.Empty, "x", String.Empty);
105 rxw.WriteValue(s.RegionInfo.RegionLocX);
106 rxw.WriteEndAttribute();
107
108 rxw.WriteStartAttribute(String.Empty, "y", String.Empty);
109 rxw.WriteValue(s.RegionInfo.RegionLocY);
110 rxw.WriteEndAttribute();
111
112 rxw.WriteStartAttribute(String.Empty, "external_hostname", String.Empty);
113 rxw.WriteString(s.RegionInfo.ExternalHostName);
114 rxw.WriteEndAttribute();
115
116 rxw.WriteStartAttribute(String.Empty, "ip", String.Empty);
117 rxw.WriteString(s.RegionInfo.InternalEndPoint.ToString());
118 rxw.WriteEndAttribute();
119
120 int users = s.GetRootAgentCount();
121 rxw.WriteStartAttribute(String.Empty, "avatars", String.Empty);
122 rxw.WriteValue(users);
123 rxw.WriteEndAttribute();
124
125 rxw.WriteStartAttribute(String.Empty, "objects", String.Empty);
126 rxw.WriteValue(s.Entities.Count - users);
127 rxw.WriteEndAttribute();
128
129 rxw.WriteEndElement();
130 }
131 }
132 return rxw.ToString();
133 }
134 #endregion GET methods
135 }
136}