aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs')
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs195
1 files changed, 195 insertions, 0 deletions
diff --git a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
new file mode 100644
index 0000000..6b1152b
--- /dev/null
+++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
@@ -0,0 +1,195 @@
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.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33
34using Nini.Config;
35using OpenSim.Framework;
36using OpenSim.Server.Base;
37using OpenSim.Services.Interfaces;
38using OpenSim.Framework.Servers.HttpServer;
39using OpenSim.Server.Handlers.Base;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41
42using log4net;
43using Nwc.XmlRpc;
44using OpenMetaverse;
45
46namespace OpenSim.Server.Handlers.Hypergrid
47{
48 public class UserAgentServerConnector : ServiceConnector
49 {
50 private static readonly ILog m_log =
51 LogManager.GetLogger(
52 MethodBase.GetCurrentMethod().DeclaringType);
53
54 private IUserAgentService m_HomeUsersService;
55
56 public UserAgentServerConnector(IConfigSource config, IHttpServer server) :
57 base(config, server, String.Empty)
58 {
59 IConfig gridConfig = config.Configs["UserAgentService"];
60 if (gridConfig != null)
61 {
62 string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty);
63 Object[] args = new Object[] { config };
64 m_HomeUsersService = ServerUtils.LoadPlugin<IUserAgentService>(serviceDll, args);
65 }
66 if (m_HomeUsersService == null)
67 throw new Exception("UserAgent server connector cannot proceed because of missing service");
68
69 server.AddXmlRPCHandler("agent_is_coming_home", AgentIsComingHome, false);
70 server.AddXmlRPCHandler("get_home_region", GetHomeRegion, false);
71 server.AddXmlRPCHandler("verify_agent", VerifyAgent, false);
72 server.AddXmlRPCHandler("verify_client", VerifyClient, false);
73 server.AddXmlRPCHandler("logout_agent", LogoutAgent, false);
74
75 server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService).Handler);
76 }
77
78 public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient)
79 {
80 Hashtable requestData = (Hashtable)request.Params[0];
81 //string host = (string)requestData["host"];
82 //string portstr = (string)requestData["port"];
83 string userID_str = (string)requestData["userID"];
84 UUID userID = UUID.Zero;
85 UUID.TryParse(userID_str, out userID);
86
87 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
88 GridRegion regInfo = m_HomeUsersService.GetHomeRegion(userID, out position, out lookAt);
89
90 Hashtable hash = new Hashtable();
91 if (regInfo == null)
92 hash["result"] = "false";
93 else
94 {
95 hash["result"] = "true";
96 hash["uuid"] = regInfo.RegionID.ToString();
97 hash["x"] = regInfo.RegionLocX.ToString();
98 hash["y"] = regInfo.RegionLocY.ToString();
99 hash["region_name"] = regInfo.RegionName;
100 hash["hostname"] = regInfo.ExternalHostName;
101 hash["http_port"] = regInfo.HttpPort.ToString();
102 hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString();
103 hash["position"] = position.ToString();
104 hash["lookAt"] = lookAt.ToString();
105 }
106 XmlRpcResponse response = new XmlRpcResponse();
107 response.Value = hash;
108 return response;
109
110 }
111
112 public XmlRpcResponse AgentIsComingHome(XmlRpcRequest request, IPEndPoint remoteClient)
113 {
114 Hashtable requestData = (Hashtable)request.Params[0];
115 //string host = (string)requestData["host"];
116 //string portstr = (string)requestData["port"];
117 string sessionID_str = (string)requestData["sessionID"];
118 UUID sessionID = UUID.Zero;
119 UUID.TryParse(sessionID_str, out sessionID);
120 string gridName = (string)requestData["externalName"];
121
122 bool success = m_HomeUsersService.AgentIsComingHome(sessionID, gridName);
123
124 Hashtable hash = new Hashtable();
125 hash["result"] = success.ToString();
126 XmlRpcResponse response = new XmlRpcResponse();
127 response.Value = hash;
128 return response;
129
130 }
131
132 public XmlRpcResponse VerifyAgent(XmlRpcRequest request, IPEndPoint remoteClient)
133 {
134 Hashtable requestData = (Hashtable)request.Params[0];
135 //string host = (string)requestData["host"];
136 //string portstr = (string)requestData["port"];
137 string sessionID_str = (string)requestData["sessionID"];
138 UUID sessionID = UUID.Zero;
139 UUID.TryParse(sessionID_str, out sessionID);
140 string token = (string)requestData["token"];
141
142 bool success = m_HomeUsersService.VerifyAgent(sessionID, token);
143
144 Hashtable hash = new Hashtable();
145 hash["result"] = success.ToString();
146 XmlRpcResponse response = new XmlRpcResponse();
147 response.Value = hash;
148 return response;
149
150 }
151
152 public XmlRpcResponse VerifyClient(XmlRpcRequest request, IPEndPoint remoteClient)
153 {
154 Hashtable requestData = (Hashtable)request.Params[0];
155 //string host = (string)requestData["host"];
156 //string portstr = (string)requestData["port"];
157 string sessionID_str = (string)requestData["sessionID"];
158 UUID sessionID = UUID.Zero;
159 UUID.TryParse(sessionID_str, out sessionID);
160 string token = (string)requestData["token"];
161
162 bool success = m_HomeUsersService.VerifyClient(sessionID, token);
163
164 Hashtable hash = new Hashtable();
165 hash["result"] = success.ToString();
166 XmlRpcResponse response = new XmlRpcResponse();
167 response.Value = hash;
168 return response;
169
170 }
171
172 public XmlRpcResponse LogoutAgent(XmlRpcRequest request, IPEndPoint remoteClient)
173 {
174 Hashtable requestData = (Hashtable)request.Params[0];
175 //string host = (string)requestData["host"];
176 //string portstr = (string)requestData["port"];
177 string sessionID_str = (string)requestData["sessionID"];
178 UUID sessionID = UUID.Zero;
179 UUID.TryParse(sessionID_str, out sessionID);
180 string userID_str = (string)requestData["userID"];
181 UUID userID = UUID.Zero;
182 UUID.TryParse(userID_str, out userID);
183
184 m_HomeUsersService.LogoutAgent(userID, sessionID);
185
186 Hashtable hash = new Hashtable();
187 hash["result"] = "true";
188 XmlRpcResponse response = new XmlRpcResponse();
189 response.Value = hash;
190 return response;
191
192 }
193
194 }
195}