diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs | 196 |
1 files changed, 175 insertions, 21 deletions
diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index 2558fa0..11adc4a 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs | |||
@@ -68,18 +68,30 @@ namespace OpenSim.Server.Handlers.Presence | |||
68 | 68 | ||
69 | try | 69 | try |
70 | { | 70 | { |
71 | Dictionary<string, string> request = | 71 | Dictionary<string, object> request = |
72 | ServerUtils.ParseQueryString(body); | 72 | ServerUtils.ParseQueryString(body); |
73 | 73 | ||
74 | if (!request.ContainsKey("METHOD")) | 74 | if (!request.ContainsKey("METHOD")) |
75 | return FailureResult(); | 75 | return FailureResult(); |
76 | 76 | ||
77 | string method = request["METHOD"]; | 77 | string method = request["METHOD"].ToString(); |
78 | 78 | ||
79 | switch (method) | 79 | switch (method) |
80 | { | 80 | { |
81 | case "login": | ||
82 | return LoginAgent(request); | ||
83 | case "logout": | ||
84 | return LogoutAgent(request); | ||
85 | case "logoutregion": | ||
86 | return LogoutRegionAgents(request); | ||
81 | case "report": | 87 | case "report": |
82 | return Report(request); | 88 | return Report(request); |
89 | case "getagent": | ||
90 | return GetAgent(request); | ||
91 | case "getagents": | ||
92 | return GetAgents(request); | ||
93 | case "sethome": | ||
94 | return SetHome(request); | ||
83 | } | 95 | } |
84 | m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method); | 96 | m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method); |
85 | } | 97 | } |
@@ -92,38 +104,153 @@ namespace OpenSim.Server.Handlers.Presence | |||
92 | 104 | ||
93 | } | 105 | } |
94 | 106 | ||
95 | byte[] Report(Dictionary<string, string> request) | 107 | byte[] LoginAgent(Dictionary<string, object> request) |
96 | { | 108 | { |
97 | PresenceInfo info = new PresenceInfo(); | 109 | string user = String.Empty; |
98 | info.Data = new Dictionary<string, string>(); | 110 | UUID session = UUID.Zero; |
111 | UUID ssession = UUID.Zero; | ||
99 | 112 | ||
100 | if (request["PrincipalID"] == null || request["RegionID"] == null) | 113 | if (!request.ContainsKey("UserID") || !request.ContainsKey("SessionID")) |
101 | return FailureResult(); | 114 | return FailureResult(); |
102 | 115 | ||
103 | if (!UUID.TryParse(request["PrincipalID"].ToString(), | 116 | user = request["UserID"].ToString(); |
104 | out info.PrincipalID)) | 117 | |
118 | if (!UUID.TryParse(request["SessionID"].ToString(), out session)) | ||
105 | return FailureResult(); | 119 | return FailureResult(); |
106 | 120 | ||
107 | if (!UUID.TryParse(request["RegionID"].ToString(), | 121 | if (request.ContainsKey("SecureSessionID")) |
108 | out info.RegionID)) | 122 | // If it's malformed, we go on with a Zero on it |
123 | UUID.TryParse(request["SecureSessionID"].ToString(), out ssession); | ||
124 | |||
125 | if (m_PresenceService.LoginAgent(user, session, ssession)) | ||
126 | return SuccessResult(); | ||
127 | |||
128 | return FailureResult(); | ||
129 | } | ||
130 | |||
131 | byte[] LogoutAgent(Dictionary<string, object> request) | ||
132 | { | ||
133 | UUID session = UUID.Zero; | ||
134 | |||
135 | if (!request.ContainsKey("SessionID")) | ||
109 | return FailureResult(); | 136 | return FailureResult(); |
110 | 137 | ||
111 | foreach (KeyValuePair<string, string> kvp in request) | 138 | if (!UUID.TryParse(request["SessionID"].ToString(), out session)) |
112 | { | 139 | return FailureResult(); |
113 | if (kvp.Key == "METHOD" || | ||
114 | kvp.Key == "PrincipalID" || | ||
115 | kvp.Key == "RegionID") | ||
116 | continue; | ||
117 | 140 | ||
118 | info.Data[kvp.Key] = kvp.Value; | 141 | if (m_PresenceService.LogoutAgent(session)) |
119 | } | 142 | return SuccessResult(); |
143 | |||
144 | return FailureResult(); | ||
145 | } | ||
146 | |||
147 | byte[] LogoutRegionAgents(Dictionary<string, object> request) | ||
148 | { | ||
149 | UUID region = UUID.Zero; | ||
150 | |||
151 | if (!request.ContainsKey("RegionID")) | ||
152 | return FailureResult(); | ||
120 | 153 | ||
121 | if (m_PresenceService.Report(info)) | 154 | if (!UUID.TryParse(request["RegionID"].ToString(), out region)) |
155 | return FailureResult(); | ||
156 | |||
157 | if (m_PresenceService.LogoutRegionAgents(region)) | ||
122 | return SuccessResult(); | 158 | return SuccessResult(); |
123 | 159 | ||
124 | return FailureResult(); | 160 | return FailureResult(); |
125 | } | 161 | } |
162 | |||
163 | byte[] Report(Dictionary<string, object> request) | ||
164 | { | ||
165 | UUID session = UUID.Zero; | ||
166 | UUID region = UUID.Zero; | ||
167 | Vector3 position = new Vector3(128, 128, 70); | ||
168 | Vector3 look = Vector3.Zero; | ||
169 | |||
170 | if (!request.ContainsKey("SessionID") || !request.ContainsKey("RegionID")) | ||
171 | return FailureResult(); | ||
172 | |||
173 | if (!UUID.TryParse(request["SessionID"].ToString(), out session)) | ||
174 | return FailureResult(); | ||
175 | |||
176 | if (!UUID.TryParse(request["RegionID"].ToString(), out region)) | ||
177 | return FailureResult(); | ||
178 | |||
179 | if (request.ContainsKey("position")) | ||
180 | Vector3.TryParse(request["position"].ToString(), out position); | ||
181 | |||
182 | if (request.ContainsKey("lookAt")) | ||
183 | Vector3.TryParse(request["lookAt"].ToString(), out look); | ||
184 | |||
185 | if (m_PresenceService.ReportAgent(session, region, position, look)) | ||
186 | return SuccessResult(); | ||
187 | |||
188 | return FailureResult(); | ||
189 | } | ||
190 | |||
191 | byte[] GetAgent(Dictionary<string, object> request) | ||
192 | { | ||
193 | UUID session = UUID.Zero; | ||
194 | |||
195 | if (!request.ContainsKey("SessionID")) | ||
196 | return FailureResult(); | ||
126 | 197 | ||
198 | if (!UUID.TryParse(request["SessionID"].ToString(), out session)) | ||
199 | return FailureResult(); | ||
200 | |||
201 | PresenceInfo pinfo = m_PresenceService.GetAgent(session); | ||
202 | |||
203 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
204 | if (pinfo == null) | ||
205 | result["result"] = "null"; | ||
206 | else | ||
207 | result["result"] = pinfo.ToKeyValuePairs(); | ||
208 | |||
209 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
210 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
211 | UTF8Encoding encoding = new UTF8Encoding(); | ||
212 | return encoding.GetBytes(xmlString); | ||
213 | } | ||
214 | |||
215 | byte[] GetAgents(Dictionary<string, object> request) | ||
216 | { | ||
217 | |||
218 | string[] userIDs; | ||
219 | |||
220 | if (!request.ContainsKey("uuids")) | ||
221 | return FailureResult(); | ||
222 | |||
223 | if (!(request["uuids"] is List<string>)) | ||
224 | { | ||
225 | m_log.DebugFormat("[PRESENCE HANDLER]: GetAgents input argument was of unexpected type {0}", request["uuids"].GetType().ToString()); | ||
226 | return FailureResult(); | ||
227 | } | ||
228 | |||
229 | userIDs = ((List<string>)request["uuids"]).ToArray(); | ||
230 | |||
231 | PresenceInfo[] pinfos = m_PresenceService.GetAgents(userIDs); | ||
232 | |||
233 | Dictionary<string, object> result = new Dictionary<string, object>(); | ||
234 | if ((pinfos == null) || ((pinfos != null) && (pinfos.Length == 0))) | ||
235 | result["result"] = "null"; | ||
236 | else | ||
237 | { | ||
238 | int i = 0; | ||
239 | foreach (PresenceInfo pinfo in pinfos) | ||
240 | { | ||
241 | Dictionary<string, object> rinfoDict = pinfo.ToKeyValuePairs(); | ||
242 | result["presence" + i] = rinfoDict; | ||
243 | i++; | ||
244 | } | ||
245 | } | ||
246 | |||
247 | string xmlString = ServerUtils.BuildXmlResponse(result); | ||
248 | //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString); | ||
249 | UTF8Encoding encoding = new UTF8Encoding(); | ||
250 | return encoding.GetBytes(xmlString); | ||
251 | } | ||
252 | |||
253 | |||
127 | private byte[] SuccessResult() | 254 | private byte[] SuccessResult() |
128 | { | 255 | { |
129 | XmlDocument doc = new XmlDocument(); | 256 | XmlDocument doc = new XmlDocument(); |
@@ -138,7 +265,7 @@ namespace OpenSim.Server.Handlers.Presence | |||
138 | 265 | ||
139 | doc.AppendChild(rootElement); | 266 | doc.AppendChild(rootElement); |
140 | 267 | ||
141 | XmlElement result = doc.CreateElement("", "Result", ""); | 268 | XmlElement result = doc.CreateElement("", "result", ""); |
142 | result.AppendChild(doc.CreateTextNode("Success")); | 269 | result.AppendChild(doc.CreateTextNode("Success")); |
143 | 270 | ||
144 | rootElement.AppendChild(result); | 271 | rootElement.AppendChild(result); |
@@ -160,7 +287,7 @@ namespace OpenSim.Server.Handlers.Presence | |||
160 | 287 | ||
161 | doc.AppendChild(rootElement); | 288 | doc.AppendChild(rootElement); |
162 | 289 | ||
163 | XmlElement result = doc.CreateElement("", "Result", ""); | 290 | XmlElement result = doc.CreateElement("", "result", ""); |
164 | result.AppendChild(doc.CreateTextNode("Failure")); | 291 | result.AppendChild(doc.CreateTextNode("Failure")); |
165 | 292 | ||
166 | rootElement.AppendChild(result); | 293 | rootElement.AppendChild(result); |
@@ -178,5 +305,32 @@ namespace OpenSim.Server.Handlers.Presence | |||
178 | 305 | ||
179 | return ms.ToArray(); | 306 | return ms.ToArray(); |
180 | } | 307 | } |
308 | |||
309 | byte[] SetHome(Dictionary<string, object> request) | ||
310 | { | ||
311 | UUID region = UUID.Zero; | ||
312 | Vector3 position = new Vector3(128, 128, 70); | ||
313 | Vector3 look = Vector3.Zero; | ||
314 | |||
315 | if (!request.ContainsKey("SessionID") || !request.ContainsKey("RegionID")) | ||
316 | return FailureResult(); | ||
317 | |||
318 | string user = request["UserID"].ToString(); | ||
319 | |||
320 | if (!UUID.TryParse(request["RegionID"].ToString(), out region)) | ||
321 | return FailureResult(); | ||
322 | |||
323 | if (request.ContainsKey("position")) | ||
324 | Vector3.TryParse(request["position"].ToString(), out position); | ||
325 | |||
326 | if (request.ContainsKey("lookAt")) | ||
327 | Vector3.TryParse(request["lookAt"].ToString(), out look); | ||
328 | |||
329 | if (m_PresenceService.SetHomeLocation(user, region, position, look)) | ||
330 | return SuccessResult(); | ||
331 | |||
332 | return FailureResult(); | ||
333 | } | ||
334 | |||
181 | } | 335 | } |
182 | } | 336 | } |