aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs143
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs1
2 files changed, 144 insertions, 0 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs
new file mode 100644
index 0000000..bd0089c
--- /dev/null
+++ b/OpenSim/ApplicationPlugins/Rest/Regions/GETRegionInfoHandler.cs
@@ -0,0 +1,143 @@
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 OpenSim 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.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35
36namespace OpenSim.ApplicationPlugins.Rest.Regions
37{
38 public partial class RestRegionPlugin : RestPlugin
39 {
40 #region GET methods
41 public string GetRegionInfoHandler(string request, string path, string param,
42 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
43 {
44 // foreach (string h in httpRequest.Headers.AllKeys)
45 // foreach (string v in httpRequest.Headers.GetValues(h))
46 // m_log.DebugFormat("{0} IsGod: {1} -> {2}", MsgID, h, v);
47
48 MsgID = RequestID;
49 m_log.DebugFormat("{0} GET path {1} param {2}", MsgID, path, param);
50
51 try
52 {
53 // param empty: regions list
54 // if (String.IsNullOrEmpty(param))
55 return GetRegionInfoHandlerRegions(httpResponse);
56
57 // // param not empty: specific region
58 // return GetRegionInfoHandlerRegion(httpResponse, param);
59 }
60 catch (Exception e)
61 {
62 return Failure(httpResponse, OSHttpStatusCode.ServerErrorInternalError, "GET", e);
63 }
64 }
65
66 public string GetRegionInfoHandlerRegions(OSHttpResponse httpResponse)
67 {
68 // regions info
69 XmlWriter.WriteStartElement(String.Empty, "regions", String.Empty);
70 {
71 // regions info: number of regions
72 XmlWriter.WriteStartAttribute(String.Empty, "number", String.Empty);
73 XmlWriter.WriteValue(App.SceneManager.Scenes.Count);
74 XmlWriter.WriteEndAttribute();
75
76 // regions info: max number of regions
77 XmlWriter.WriteStartAttribute(String.Empty, "max", String.Empty);
78 if (App.ConfigSource.Source.Configs["RemoteAdmin"] != null)
79 {
80 XmlWriter.WriteValue(App.ConfigSource.Source.Configs["RemoteAdmin"].GetInt("region_limit", -1));
81 }
82 else
83 {
84 XmlWriter.WriteValue(-1);
85 }
86 XmlWriter.WriteEndAttribute();
87
88 // regions info: region
89 foreach (Scene s in App.SceneManager.Scenes)
90 {
91 XmlWriter.WriteStartElement(String.Empty, "region", String.Empty);
92
93 XmlWriter.WriteStartAttribute(String.Empty, "uuid", String.Empty);
94 XmlWriter.WriteString(s.RegionInfo.RegionID.ToString());
95 XmlWriter.WriteEndAttribute();
96
97 XmlWriter.WriteStartAttribute(String.Empty, "name", String.Empty);
98 XmlWriter.WriteString(s.RegionInfo.RegionName);
99 XmlWriter.WriteEndAttribute();
100
101 XmlWriter.WriteStartAttribute(String.Empty, "x", String.Empty);
102 XmlWriter.WriteValue(s.RegionInfo.RegionLocX);
103 XmlWriter.WriteEndAttribute();
104
105 XmlWriter.WriteStartAttribute(String.Empty, "y", String.Empty);
106 XmlWriter.WriteValue(s.RegionInfo.RegionLocY);
107 XmlWriter.WriteEndAttribute();
108
109 XmlWriter.WriteStartAttribute(String.Empty, "external_hostname", String.Empty);
110 XmlWriter.WriteString(s.RegionInfo.ExternalHostName);
111 XmlWriter.WriteEndAttribute();
112
113 XmlWriter.WriteStartAttribute(String.Empty, "master_name", String.Empty);
114 XmlWriter.WriteString(String.Format("{0} {1}", s.RegionInfo.MasterAvatarFirstName, s.RegionInfo.MasterAvatarLastName));
115 XmlWriter.WriteEndAttribute();
116
117 XmlWriter.WriteStartAttribute(String.Empty, "master_uuid", String.Empty);
118 XmlWriter.WriteString(s.RegionInfo.MasterAvatarAssignedUUID.ToString());
119 XmlWriter.WriteEndAttribute();
120
121 XmlWriter.WriteStartAttribute(String.Empty, "ip", String.Empty);
122 XmlWriter.WriteString(s.RegionInfo.InternalEndPoint.ToString());
123 XmlWriter.WriteEndAttribute();
124
125 int users = s.GetAvatars().Count;
126 XmlWriter.WriteStartAttribute(String.Empty, "avatars", String.Empty);
127 XmlWriter.WriteValue(users);
128 XmlWriter.WriteEndAttribute();
129
130 XmlWriter.WriteStartAttribute(String.Empty, "objects", String.Empty);
131 XmlWriter.WriteValue(s.Entities.Count - users);
132 XmlWriter.WriteEndAttribute();
133
134 XmlWriter.WriteEndElement();
135 }
136 }
137 XmlWriter.WriteEndElement();
138
139 return XmlWriterResult;
140 }
141 #endregion GET methods
142 }
143}
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs b/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs
index fdfeb7d..ef72f71 100644
--- a/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Regions/RestRegionPlugin.cs
@@ -76,6 +76,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
76 // add REST method handlers 76 // add REST method handlers
77 AddRestStreamHandler("GET", "/regions/", GetHandler); 77 AddRestStreamHandler("GET", "/regions/", GetHandler);
78 AddRestStreamHandler("POST", "/regions/", PostHandler); 78 AddRestStreamHandler("POST", "/regions/", PostHandler);
79 AddRestStreamHandler("GET", "/regioninfo/", GetRegionInfoHandler);
79 } 80 }
80 catch (Exception e) 81 catch (Exception e)
81 { 82 {