diff options
author | Diva Canto | 2010-01-16 21:42:44 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-16 21:42:44 -0800 |
commit | 04e29c1bacbc1e2df980ae15896a847ce7535da2 (patch) | |
tree | e799d2837af1a41bc2c3b2d571201e9a8a6d7ae7 /OpenSim/Server | |
parent | Finished moving object crossings into EntityTransferModule (diff) | |
download | opensim-SC-04e29c1bacbc1e2df980ae15896a847ce7535da2.zip opensim-SC-04e29c1bacbc1e2df980ae15896a847ce7535da2.tar.gz opensim-SC-04e29c1bacbc1e2df980ae15896a847ce7535da2.tar.bz2 opensim-SC-04e29c1bacbc1e2df980ae15896a847ce7535da2.tar.xz |
Beginning of rewriting HG. Compiles, and runs, but HG functions not restored yet.
Diffstat (limited to 'OpenSim/Server')
-rw-r--r-- | OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs new file mode 100644 index 0000000..ec8dde4 --- /dev/null +++ b/OpenSim/Server/Handlers/Hypergrid/GatekeeperServerConnector.cs | |||
@@ -0,0 +1,140 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using System.Net; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Server.Base; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using OpenSim.Framework.Servers.HttpServer; | ||
38 | using OpenSim.Server.Handlers.Base; | ||
39 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
40 | |||
41 | using OpenMetaverse; | ||
42 | using log4net; | ||
43 | using Nwc.XmlRpc; | ||
44 | |||
45 | namespace OpenSim.Server.Handlers.Hypergrid | ||
46 | { | ||
47 | public class GatekeeperServiceInConnector : ServiceConnector | ||
48 | { | ||
49 | private static readonly ILog m_log = | ||
50 | LogManager.GetLogger( | ||
51 | MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | private IGatekeeperService m_GatekeeperService; | ||
54 | |||
55 | public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server, ISimulationService simService) : | ||
56 | base(config, server, String.Empty) | ||
57 | { | ||
58 | IConfig gridConfig = config.Configs["GatekeeperService"]; | ||
59 | if (gridConfig != null) | ||
60 | { | ||
61 | string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty); | ||
62 | Object[] args = new Object[] { config, simService }; | ||
63 | m_GatekeeperService = ServerUtils.LoadPlugin<IGatekeeperService>(serviceDll, args); | ||
64 | } | ||
65 | if (m_GatekeeperService == null) | ||
66 | throw new Exception("Gatekeeper server connector cannot proceed because of missing service"); | ||
67 | |||
68 | server.AddXmlRPCHandler("link_region", LinkRegionRequest, false); | ||
69 | server.AddXmlRPCHandler("get_region", GetRegion, false); | ||
70 | } | ||
71 | |||
72 | public GatekeeperServiceInConnector(IConfigSource config, IHttpServer server) | ||
73 | : this(config, server, null) | ||
74 | { | ||
75 | } | ||
76 | |||
77 | /// <summary> | ||
78 | /// Someone wants to link to us | ||
79 | /// </summary> | ||
80 | /// <param name="request"></param> | ||
81 | /// <returns></returns> | ||
82 | public XmlRpcResponse LinkRegionRequest(XmlRpcRequest request, IPEndPoint remoteClient) | ||
83 | { | ||
84 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
85 | //string host = (string)requestData["host"]; | ||
86 | //string portstr = (string)requestData["port"]; | ||
87 | string name = (string)requestData["region_name"]; | ||
88 | |||
89 | m_log.DebugFormat("[HGrid]: Hyperlink request"); | ||
90 | |||
91 | UUID regionID = UUID.Zero; | ||
92 | string imageURL = string.Empty; | ||
93 | ulong regionHandle = 0; | ||
94 | string reason = string.Empty; | ||
95 | |||
96 | bool success = m_GatekeeperService.LinkRegion(name, out regionID, out regionHandle, out imageURL, out reason); | ||
97 | |||
98 | Hashtable hash = new Hashtable(); | ||
99 | hash["result"] = success.ToString(); | ||
100 | hash["uuid"] = regionID.ToString(); | ||
101 | hash["handle"] = regionHandle.ToString(); | ||
102 | hash["region_image"] = imageURL; | ||
103 | |||
104 | XmlRpcResponse response = new XmlRpcResponse(); | ||
105 | response.Value = hash; | ||
106 | return response; | ||
107 | } | ||
108 | |||
109 | public XmlRpcResponse GetRegion(XmlRpcRequest request, IPEndPoint remoteClient) | ||
110 | { | ||
111 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
112 | //string host = (string)requestData["host"]; | ||
113 | //string portstr = (string)requestData["port"]; | ||
114 | string regionID_str = (string)requestData["regionID"]; | ||
115 | UUID regionID = UUID.Zero; | ||
116 | UUID.TryParse(regionID_str, out regionID); | ||
117 | |||
118 | GridRegion regInfo = m_GatekeeperService.GetHyperlinkRegion(regionID); | ||
119 | |||
120 | Hashtable hash = new Hashtable(); | ||
121 | if (regInfo == null) | ||
122 | hash["result"] = "false"; | ||
123 | else | ||
124 | { | ||
125 | hash["result"] = "true"; | ||
126 | hash["uuid"] = regInfo.RegionID.ToString(); | ||
127 | hash["x"] = regInfo.RegionLocX.ToString(); | ||
128 | hash["y"] = regInfo.RegionLocY.ToString(); | ||
129 | hash["region_name"] = regInfo.RegionName; | ||
130 | hash["hostname"] = regInfo.ExternalHostName; | ||
131 | hash["http_port"] = regInfo.HttpPort.ToString(); | ||
132 | hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); | ||
133 | } | ||
134 | XmlRpcResponse response = new XmlRpcResponse(); | ||
135 | response.Value = hash; | ||
136 | return response; | ||
137 | |||
138 | } | ||
139 | } | ||
140 | } | ||