aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Presence
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server/Handlers/Presence')
-rw-r--r--OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs205
1 files changed, 184 insertions, 21 deletions
diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs
index b5ae54a..d180bbb 100644
--- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs
@@ -65,7 +65,7 @@ namespace OpenSim.Server.Handlers.Presence
65 body = body.Trim(); 65 body = body.Trim();
66 66
67 //m_log.DebugFormat("[XXX]: query String: {0}", body); 67 //m_log.DebugFormat("[XXX]: query String: {0}", body);
68 68 string method = string.Empty;
69 try 69 try
70 { 70 {
71 Dictionary<string, object> request = 71 Dictionary<string, object> request =
@@ -74,56 +74,192 @@ namespace OpenSim.Server.Handlers.Presence
74 if (!request.ContainsKey("METHOD")) 74 if (!request.ContainsKey("METHOD"))
75 return FailureResult(); 75 return FailureResult();
76 76
77 string method = request["METHOD"].ToString(); 77 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 }
86 catch (Exception e) 98 catch (Exception e)
87 { 99 {
88 m_log.Debug("[PRESENCE HANDLER]: Exception {0}" + e); 100 m_log.DebugFormat("[PRESENCE HANDLER]: Exception in method {0}: {1}", method, e);
89 } 101 }
90 102
91 return FailureResult(); 103 return FailureResult();
92 104
93 } 105 }
94 106
107 byte[] LoginAgent(Dictionary<string, object> request)
108 {
109 string user = String.Empty;
110 UUID session = UUID.Zero;
111 UUID ssession = UUID.Zero;
112
113 if (!request.ContainsKey("UserID") || !request.ContainsKey("SessionID"))
114 return FailureResult();
115
116 user = request["UserID"].ToString();
117
118 if (!UUID.TryParse(request["SessionID"].ToString(), out session))
119 return FailureResult();
120
121 if (request.ContainsKey("SecureSessionID"))
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 Vector3 position = Vector3.Zero;
135 Vector3 lookat = Vector3.Zero;
136
137 if (!request.ContainsKey("SessionID"))
138 return FailureResult();
139
140 if (!UUID.TryParse(request["SessionID"].ToString(), out session))
141 return FailureResult();
142
143 if (request.ContainsKey("Position") && request["Position"] != null)
144 Vector3.TryParse(request["Position"].ToString(), out position);
145 if (request.ContainsKey("LookAt") && request["Position"] != null)
146 Vector3.TryParse(request["LookAt"].ToString(), out lookat);
147
148 if (m_PresenceService.LogoutAgent(session, position, lookat))
149 return SuccessResult();
150
151 return FailureResult();
152 }
153
154 byte[] LogoutRegionAgents(Dictionary<string, object> request)
155 {
156 UUID region = UUID.Zero;
157
158 if (!request.ContainsKey("RegionID"))
159 return FailureResult();
160
161 if (!UUID.TryParse(request["RegionID"].ToString(), out region))
162 return FailureResult();
163
164 if (m_PresenceService.LogoutRegionAgents(region))
165 return SuccessResult();
166
167 return FailureResult();
168 }
169
95 byte[] Report(Dictionary<string, object> request) 170 byte[] Report(Dictionary<string, object> request)
96 { 171 {
97 PresenceInfo info = new PresenceInfo(); 172 UUID session = UUID.Zero;
98 info.Data = new Dictionary<string, string>(); 173 UUID region = UUID.Zero;
174 Vector3 position = new Vector3(128, 128, 70);
175 Vector3 look = Vector3.Zero;
99 176
100 if (!request.ContainsKey("PrincipalID") || !request.ContainsKey("RegionID")) 177 if (!request.ContainsKey("SessionID") || !request.ContainsKey("RegionID"))
101 return FailureResult(); 178 return FailureResult();
102 179
103 if (!UUID.TryParse(request["PrincipalID"].ToString(), 180 if (!UUID.TryParse(request["SessionID"].ToString(), out session))
104 out info.PrincipalID))
105 return FailureResult(); 181 return FailureResult();
106 182
107 if (!UUID.TryParse(request["RegionID"].ToString(), 183 if (!UUID.TryParse(request["RegionID"].ToString(), out region))
108 out info.RegionID))
109 return FailureResult(); 184 return FailureResult();
110 185
111 foreach (KeyValuePair<string, object> kvp in request) 186 if (request.ContainsKey("position"))
112 { 187 Vector3.TryParse(request["position"].ToString(), out position);
113 if (kvp.Key == "METHOD" ||
114 kvp.Key == "PrincipalID" ||
115 kvp.Key == "RegionID")
116 continue;
117 188
118 info.Data[kvp.Key] = kvp.Value.ToString(); 189 if (request.ContainsKey("lookAt"))
119 } 190 Vector3.TryParse(request["lookAt"].ToString(), out look);
120 191
121 if (m_PresenceService.Report(info)) 192 if (m_PresenceService.ReportAgent(session, region, position, look))
193 {
122 return SuccessResult(); 194 return SuccessResult();
195 }
123 196
124 return FailureResult(); 197 return FailureResult();
125 } 198 }
126 199
200 byte[] GetAgent(Dictionary<string, object> request)
201 {
202 UUID session = UUID.Zero;
203
204 if (!request.ContainsKey("SessionID"))
205 return FailureResult();
206
207 if (!UUID.TryParse(request["SessionID"].ToString(), out session))
208 return FailureResult();
209
210 PresenceInfo pinfo = m_PresenceService.GetAgent(session);
211
212 Dictionary<string, object> result = new Dictionary<string, object>();
213 if (pinfo == null)
214 result["result"] = "null";
215 else
216 result["result"] = pinfo.ToKeyValuePairs();
217
218 string xmlString = ServerUtils.BuildXmlResponse(result);
219 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
220 UTF8Encoding encoding = new UTF8Encoding();
221 return encoding.GetBytes(xmlString);
222 }
223
224 byte[] GetAgents(Dictionary<string, object> request)
225 {
226
227 string[] userIDs;
228
229 if (!request.ContainsKey("uuids"))
230 return FailureResult();
231
232 if (!(request["uuids"] is List<string>))
233 {
234 m_log.DebugFormat("[PRESENCE HANDLER]: GetAgents input argument was of unexpected type {0}", request["uuids"].GetType().ToString());
235 return FailureResult();
236 }
237
238 userIDs = ((List<string>)request["uuids"]).ToArray();
239
240 PresenceInfo[] pinfos = m_PresenceService.GetAgents(userIDs);
241
242 Dictionary<string, object> result = new Dictionary<string, object>();
243 if ((pinfos == null) || ((pinfos != null) && (pinfos.Length == 0)))
244 result["result"] = "null";
245 else
246 {
247 int i = 0;
248 foreach (PresenceInfo pinfo in pinfos)
249 {
250 Dictionary<string, object> rinfoDict = pinfo.ToKeyValuePairs();
251 result["presence" + i] = rinfoDict;
252 i++;
253 }
254 }
255
256 string xmlString = ServerUtils.BuildXmlResponse(result);
257 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
258 UTF8Encoding encoding = new UTF8Encoding();
259 return encoding.GetBytes(xmlString);
260 }
261
262
127 private byte[] SuccessResult() 263 private byte[] SuccessResult()
128 { 264 {
129 XmlDocument doc = new XmlDocument(); 265 XmlDocument doc = new XmlDocument();
@@ -138,7 +274,7 @@ namespace OpenSim.Server.Handlers.Presence
138 274
139 doc.AppendChild(rootElement); 275 doc.AppendChild(rootElement);
140 276
141 XmlElement result = doc.CreateElement("", "Result", ""); 277 XmlElement result = doc.CreateElement("", "result", "");
142 result.AppendChild(doc.CreateTextNode("Success")); 278 result.AppendChild(doc.CreateTextNode("Success"));
143 279
144 rootElement.AppendChild(result); 280 rootElement.AppendChild(result);
@@ -160,7 +296,7 @@ namespace OpenSim.Server.Handlers.Presence
160 296
161 doc.AppendChild(rootElement); 297 doc.AppendChild(rootElement);
162 298
163 XmlElement result = doc.CreateElement("", "Result", ""); 299 XmlElement result = doc.CreateElement("", "result", "");
164 result.AppendChild(doc.CreateTextNode("Failure")); 300 result.AppendChild(doc.CreateTextNode("Failure"));
165 301
166 rootElement.AppendChild(result); 302 rootElement.AppendChild(result);
@@ -178,5 +314,32 @@ namespace OpenSim.Server.Handlers.Presence
178 314
179 return ms.ToArray(); 315 return ms.ToArray();
180 } 316 }
317
318 byte[] SetHome(Dictionary<string, object> request)
319 {
320 UUID region = UUID.Zero;
321 Vector3 position = new Vector3(128, 128, 70);
322 Vector3 look = Vector3.Zero;
323
324 if (!request.ContainsKey("UserID") || !request.ContainsKey("RegionID"))
325 return FailureResult();
326
327 string user = request["UserID"].ToString();
328
329 if (!UUID.TryParse(request["RegionID"].ToString(), out region))
330 return FailureResult();
331
332 if (request.ContainsKey("position"))
333 Vector3.TryParse(request["position"].ToString(), out position);
334
335 if (request.ContainsKey("lookAt"))
336 Vector3.TryParse(request["lookAt"].ToString(), out look);
337
338 if (m_PresenceService.SetHomeLocation(user, region, position, look))
339 return SuccessResult();
340
341 return FailureResult();
342 }
343
181 } 344 }
182} 345}