diff options
Diffstat (limited to 'OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs')
-rw-r--r-- | OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs new file mode 100644 index 0000000..5d03097 --- /dev/null +++ b/OpenSim/Server/Handlers/Hypergrid/HypergridHandlers.cs | |||
@@ -0,0 +1,120 @@ | |||
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 | using System; | ||
28 | using System.Collections; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using OpenSim.Services.Interfaces; | ||
34 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
35 | |||
36 | using log4net; | ||
37 | using Nwc.XmlRpc; | ||
38 | using OpenMetaverse; | ||
39 | |||
40 | namespace OpenSim.Server.Handlers.Hypergrid | ||
41 | { | ||
42 | public class HypergridHandlers | ||
43 | { | ||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
45 | |||
46 | private IGatekeeperService m_GatekeeperService; | ||
47 | |||
48 | public HypergridHandlers(IGatekeeperService gatekeeper) | ||
49 | { | ||
50 | m_GatekeeperService = gatekeeper; | ||
51 | m_log.DebugFormat("[HYPERGRID HANDLERS]: Active"); | ||
52 | } | ||
53 | |||
54 | /// <summary> | ||
55 | /// Someone wants to link to us | ||
56 | /// </summary> | ||
57 | /// <param name="request"></param> | ||
58 | /// <returns></returns> | ||
59 | public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient) | ||
60 | { | ||
61 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
62 | //string host = (string)requestData["host"]; | ||
63 | //string portstr = (string)requestData["port"]; | ||
64 | string name = (string)requestData["region_name"]; | ||
65 | if (name == null) | ||
66 | name = string.Empty; | ||
67 | |||
68 | UUID regionID = UUID.Zero; | ||
69 | string externalName = string.Empty; | ||
70 | string imageURL = string.Empty; | ||
71 | ulong regionHandle = 0; | ||
72 | string reason = string.Empty; | ||
73 | |||
74 | bool success = m_GatekeeperService.LinkRegion(name, out regionID, out regionHandle, out externalName, out imageURL, out reason); | ||
75 | |||
76 | Hashtable hash = new Hashtable(); | ||
77 | hash["result"] = success.ToString(); | ||
78 | hash["uuid"] = regionID.ToString(); | ||
79 | hash["handle"] = regionHandle.ToString(); | ||
80 | hash["region_image"] = imageURL; | ||
81 | hash["external_name"] = externalName; | ||
82 | |||
83 | XmlRpcResponse response = new XmlRpcResponse(); | ||
84 | response.Value = hash; | ||
85 | return response; | ||
86 | } | ||
87 | |||
88 | public XmlRpcResponse GetRegion(XmlRpcRequest request, IPEndPoint remoteClient) | ||
89 | { | ||
90 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
91 | //string host = (string)requestData["host"]; | ||
92 | //string portstr = (string)requestData["port"]; | ||
93 | string regionID_str = (string)requestData["region_uuid"]; | ||
94 | UUID regionID = UUID.Zero; | ||
95 | UUID.TryParse(regionID_str, out regionID); | ||
96 | |||
97 | GridRegion regInfo = m_GatekeeperService.GetHyperlinkRegion(regionID); | ||
98 | |||
99 | Hashtable hash = new Hashtable(); | ||
100 | if (regInfo == null) | ||
101 | hash["result"] = "false"; | ||
102 | else | ||
103 | { | ||
104 | hash["result"] = "true"; | ||
105 | hash["uuid"] = regInfo.RegionID.ToString(); | ||
106 | hash["x"] = regInfo.RegionLocX.ToString(); | ||
107 | hash["y"] = regInfo.RegionLocY.ToString(); | ||
108 | hash["region_name"] = regInfo.RegionName; | ||
109 | hash["hostname"] = regInfo.ExternalHostName; | ||
110 | hash["http_port"] = regInfo.HttpPort.ToString(); | ||
111 | hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); | ||
112 | } | ||
113 | XmlRpcResponse response = new XmlRpcResponse(); | ||
114 | response.Value = hash; | ||
115 | return response; | ||
116 | |||
117 | } | ||
118 | |||
119 | } | ||
120 | } | ||