diff options
author | Diva Canto | 2010-01-28 19:19:42 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-28 19:19:42 -0800 |
commit | 00f7d622cbc2c2e61d2efaacd8275da3f9821d8b (patch) | |
tree | 1bfc6dd3ac2a93443bc75baa03ceefba4cfacc1e /OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs | |
parent | Added ExternalName config on Gatekeeper. (diff) | |
download | opensim-SC-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.zip opensim-SC-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.tar.gz opensim-SC-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.tar.bz2 opensim-SC-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.tar.xz |
HG 1.5 is in place. Tested in standalone only.
Diffstat (limited to 'OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs')
-rw-r--r-- | OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs | 168 |
1 files changed, 168 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..79c6b2a --- /dev/null +++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs | |||
@@ -0,0 +1,168 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Net; | ||
5 | using System.Reflection; | ||
6 | |||
7 | using Nini.Config; | ||
8 | using OpenSim.Framework; | ||
9 | using OpenSim.Server.Base; | ||
10 | using OpenSim.Services.Interfaces; | ||
11 | using OpenSim.Framework.Servers.HttpServer; | ||
12 | using OpenSim.Server.Handlers.Base; | ||
13 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
14 | |||
15 | using log4net; | ||
16 | using Nwc.XmlRpc; | ||
17 | using OpenMetaverse; | ||
18 | |||
19 | namespace OpenSim.Server.Handlers.Hypergrid | ||
20 | { | ||
21 | public class UserAgentServerConnector : ServiceConnector | ||
22 | { | ||
23 | private static readonly ILog m_log = | ||
24 | LogManager.GetLogger( | ||
25 | MethodBase.GetCurrentMethod().DeclaringType); | ||
26 | |||
27 | private IUserAgentService m_HomeUsersService; | ||
28 | |||
29 | public UserAgentServerConnector(IConfigSource config, IHttpServer server) : | ||
30 | base(config, server, String.Empty) | ||
31 | { | ||
32 | IConfig gridConfig = config.Configs["UserAgentService"]; | ||
33 | if (gridConfig != null) | ||
34 | { | ||
35 | string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty); | ||
36 | Object[] args = new Object[] { config }; | ||
37 | m_HomeUsersService = ServerUtils.LoadPlugin<IUserAgentService>(serviceDll, args); | ||
38 | } | ||
39 | if (m_HomeUsersService == null) | ||
40 | throw new Exception("UserAgent server connector cannot proceed because of missing service"); | ||
41 | |||
42 | server.AddXmlRPCHandler("agent_is_coming_home", AgentIsComingHome, false); | ||
43 | server.AddXmlRPCHandler("get_home_region", GetHomeRegion, false); | ||
44 | server.AddXmlRPCHandler("verify_agent", VerifyAgent, false); | ||
45 | server.AddXmlRPCHandler("verify_client", VerifyClient, false); | ||
46 | server.AddXmlRPCHandler("logout_agent", LogoutAgent, false); | ||
47 | |||
48 | server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService).Handler); | ||
49 | } | ||
50 | |||
51 | public XmlRpcResponse GetHomeRegion(XmlRpcRequest request, IPEndPoint remoteClient) | ||
52 | { | ||
53 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
54 | //string host = (string)requestData["host"]; | ||
55 | //string portstr = (string)requestData["port"]; | ||
56 | string userID_str = (string)requestData["userID"]; | ||
57 | UUID userID = UUID.Zero; | ||
58 | UUID.TryParse(userID_str, out userID); | ||
59 | |||
60 | Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; | ||
61 | GridRegion regInfo = m_HomeUsersService.GetHomeRegion(userID, out position, out lookAt); | ||
62 | |||
63 | Hashtable hash = new Hashtable(); | ||
64 | if (regInfo == null) | ||
65 | hash["result"] = "false"; | ||
66 | else | ||
67 | { | ||
68 | hash["result"] = "true"; | ||
69 | hash["uuid"] = regInfo.RegionID.ToString(); | ||
70 | hash["x"] = regInfo.RegionLocX.ToString(); | ||
71 | hash["y"] = regInfo.RegionLocY.ToString(); | ||
72 | hash["region_name"] = regInfo.RegionName; | ||
73 | hash["hostname"] = regInfo.ExternalHostName; | ||
74 | hash["http_port"] = regInfo.HttpPort.ToString(); | ||
75 | hash["internal_port"] = regInfo.InternalEndPoint.Port.ToString(); | ||
76 | hash["position"] = position.ToString(); | ||
77 | hash["lookAt"] = lookAt.ToString(); | ||
78 | } | ||
79 | XmlRpcResponse response = new XmlRpcResponse(); | ||
80 | response.Value = hash; | ||
81 | return response; | ||
82 | |||
83 | } | ||
84 | |||
85 | public XmlRpcResponse AgentIsComingHome(XmlRpcRequest request, IPEndPoint remoteClient) | ||
86 | { | ||
87 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
88 | //string host = (string)requestData["host"]; | ||
89 | //string portstr = (string)requestData["port"]; | ||
90 | string sessionID_str = (string)requestData["sessionID"]; | ||
91 | UUID sessionID = UUID.Zero; | ||
92 | UUID.TryParse(sessionID_str, out sessionID); | ||
93 | string gridName = (string)requestData["externalName"]; | ||
94 | |||
95 | bool success = m_HomeUsersService.AgentIsComingHome(sessionID, gridName); | ||
96 | |||
97 | Hashtable hash = new Hashtable(); | ||
98 | hash["result"] = success.ToString(); | ||
99 | XmlRpcResponse response = new XmlRpcResponse(); | ||
100 | response.Value = hash; | ||
101 | return response; | ||
102 | |||
103 | } | ||
104 | |||
105 | public XmlRpcResponse VerifyAgent(XmlRpcRequest request, IPEndPoint remoteClient) | ||
106 | { | ||
107 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
108 | //string host = (string)requestData["host"]; | ||
109 | //string portstr = (string)requestData["port"]; | ||
110 | string sessionID_str = (string)requestData["sessionID"]; | ||
111 | UUID sessionID = UUID.Zero; | ||
112 | UUID.TryParse(sessionID_str, out sessionID); | ||
113 | string token = (string)requestData["token"]; | ||
114 | |||
115 | bool success = m_HomeUsersService.VerifyAgent(sessionID, token); | ||
116 | |||
117 | Hashtable hash = new Hashtable(); | ||
118 | hash["result"] = success.ToString(); | ||
119 | XmlRpcResponse response = new XmlRpcResponse(); | ||
120 | response.Value = hash; | ||
121 | return response; | ||
122 | |||
123 | } | ||
124 | |||
125 | public XmlRpcResponse VerifyClient(XmlRpcRequest request, IPEndPoint remoteClient) | ||
126 | { | ||
127 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
128 | //string host = (string)requestData["host"]; | ||
129 | //string portstr = (string)requestData["port"]; | ||
130 | string sessionID_str = (string)requestData["sessionID"]; | ||
131 | UUID sessionID = UUID.Zero; | ||
132 | UUID.TryParse(sessionID_str, out sessionID); | ||
133 | string token = (string)requestData["token"]; | ||
134 | |||
135 | bool success = m_HomeUsersService.VerifyClient(sessionID, token); | ||
136 | |||
137 | Hashtable hash = new Hashtable(); | ||
138 | hash["result"] = success.ToString(); | ||
139 | XmlRpcResponse response = new XmlRpcResponse(); | ||
140 | response.Value = hash; | ||
141 | return response; | ||
142 | |||
143 | } | ||
144 | |||
145 | public XmlRpcResponse LogoutAgent(XmlRpcRequest request, IPEndPoint remoteClient) | ||
146 | { | ||
147 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
148 | //string host = (string)requestData["host"]; | ||
149 | //string portstr = (string)requestData["port"]; | ||
150 | string sessionID_str = (string)requestData["sessionID"]; | ||
151 | UUID sessionID = UUID.Zero; | ||
152 | UUID.TryParse(sessionID_str, out sessionID); | ||
153 | string userID_str = (string)requestData["userID"]; | ||
154 | UUID userID = UUID.Zero; | ||
155 | UUID.TryParse(userID_str, out userID); | ||
156 | |||
157 | m_HomeUsersService.LogoutAgent(userID, sessionID); | ||
158 | |||
159 | Hashtable hash = new Hashtable(); | ||
160 | hash["result"] = "true"; | ||
161 | XmlRpcResponse response = new XmlRpcResponse(); | ||
162 | response.Value = hash; | ||
163 | return response; | ||
164 | |||
165 | } | ||
166 | |||
167 | } | ||
168 | } | ||