aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Presence
diff options
context:
space:
mode:
authorDiva Canto2009-12-27 20:34:42 -0800
committerDiva Canto2009-12-27 20:34:42 -0800
commit3ef513e863097bdccffa8c84283ab8ffc0915a8f (patch)
tree0e388f2a40f738b4f48e48d833d545b6eb70528b /OpenSim/Server/Handlers/Presence
parentChanged GetAgents to take string[] instead of UUID[] (diff)
downloadopensim-SC-3ef513e863097bdccffa8c84283ab8ffc0915a8f.zip
opensim-SC-3ef513e863097bdccffa8c84283ab8ffc0915a8f.tar.gz
opensim-SC-3ef513e863097bdccffa8c84283ab8ffc0915a8f.tar.bz2
opensim-SC-3ef513e863097bdccffa8c84283ab8ffc0915a8f.tar.xz
Presence remote connector and handler. Presence HG Broker. Nothing tested, just compiles.
Diffstat (limited to 'OpenSim/Server/Handlers/Presence')
-rw-r--r--OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs152
1 files changed, 144 insertions, 8 deletions
diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs
index d914d32..b02c2ed 100644
--- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs
@@ -78,8 +78,18 @@ namespace OpenSim.Server.Handlers.Presence
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);
83 } 93 }
84 m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method); 94 m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method);
85 } 95 }
@@ -92,28 +102,154 @@ namespace OpenSim.Server.Handlers.Presence
92 102
93 } 103 }
94 104
105 byte[] LoginAgent(Dictionary<string, object> request)
106 {
107 UUID principal = UUID.Zero;
108 UUID session = UUID.Zero;
109 UUID ssession = UUID.Zero;
110
111 if (!request.ContainsKey("PrincipalID") || !request.ContainsKey("SessionID"))
112 return FailureResult();
113
114 if (!UUID.TryParse(request["PrincipalID"].ToString(), out principal))
115 return FailureResult();
116
117 if (!UUID.TryParse(request["SessionID"].ToString(), out session))
118 return FailureResult();
119
120 if (request.ContainsKey("SecureSessionID"))
121 // If it's malformed, we go on with a Zero on it
122 UUID.TryParse(request["SecureSessionID"].ToString(), out ssession);
123
124 if (m_PresenceService.LoginAgent(principal, session, ssession))
125 return SuccessResult();
126
127 return FailureResult();
128 }
129
130 byte[] LogoutAgent(Dictionary<string, object> request)
131 {
132 UUID session = UUID.Zero;
133
134 if (!request.ContainsKey("SessionID"))
135 return FailureResult();
136
137 if (!UUID.TryParse(request["SessionID"].ToString(), out session))
138 return FailureResult();
139
140 if (m_PresenceService.LogoutAgent(session))
141 return SuccessResult();
142
143 return FailureResult();
144 }
145
146 byte[] LogoutRegionAgents(Dictionary<string, object> request)
147 {
148 UUID region = UUID.Zero;
149
150 if (!request.ContainsKey("RegionID"))
151 return FailureResult();
152
153 if (!UUID.TryParse(request["RegionID"].ToString(), out region))
154 return FailureResult();
155
156 if (m_PresenceService.LogoutRegionAgents(region))
157 return SuccessResult();
158
159 return FailureResult();
160 }
161
95 byte[] Report(Dictionary<string, object> request) 162 byte[] Report(Dictionary<string, object> request)
96 { 163 {
97 PresenceInfo info = new PresenceInfo(); 164 UUID session = UUID.Zero;
165 UUID region = UUID.Zero;
166 Vector3 position = new Vector3(128, 128, 70);
167 Vector3 look = Vector3.Zero;
98 168
99 if (!request.ContainsKey("PrincipalID") || !request.ContainsKey("RegionID")) 169 if (!request.ContainsKey("SessionID") || !request.ContainsKey("RegionID"))
100 return FailureResult(); 170 return FailureResult();
101 171
102 if (!UUID.TryParse(request["PrincipalID"].ToString(), 172 if (!UUID.TryParse(request["SessionID"].ToString(), out session))
103 out info.PrincipalID))
104 return FailureResult(); 173 return FailureResult();
105 174
106 if (!UUID.TryParse(request["RegionID"].ToString(), 175 if (!UUID.TryParse(request["RegionID"].ToString(), out region))
107 out info.RegionID))
108 return FailureResult(); 176 return FailureResult();
109 177
178 if (request.ContainsKey("position"))
179 Vector3.TryParse(request["position"].ToString(), out position);
110 180
111// if (m_PresenceService.ReportAgent(info)) 181 if (request.ContainsKey("lookAt"))
112// return SuccessResult(); 182 Vector3.TryParse(request["lookAt"].ToString(), out look);
183
184 if (m_PresenceService.ReportAgent(session, region, position, look))
185 return SuccessResult();
113 186
114 return FailureResult(); 187 return FailureResult();
115 } 188 }
116 189
190 byte[] GetAgent(Dictionary<string, object> request)
191 {
192 UUID session = UUID.Zero;
193
194 if (!request.ContainsKey("SessionID"))
195 return FailureResult();
196
197 if (!UUID.TryParse(request["SessionID"].ToString(), out session))
198 return FailureResult();
199
200 PresenceInfo pinfo = m_PresenceService.GetAgent(session);
201
202 Dictionary<string, object> result = new Dictionary<string, object>();
203 if (pinfo == null)
204 result["result"] = "null";
205 else
206 result["result"] = pinfo.ToKeyValuePairs();
207
208 string xmlString = ServerUtils.BuildXmlResponse(result);
209 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
210 UTF8Encoding encoding = new UTF8Encoding();
211 return encoding.GetBytes(xmlString);
212 }
213
214 byte[] GetAgents(Dictionary<string, object> request)
215 {
216
217 string[] userIDs;
218
219 if (!request.ContainsKey("uuids"))
220 return FailureResult();
221
222 if (!(request["uuids"] is List<string>))
223 {
224 m_log.DebugFormat("[PRESENCE HANDLER]: GetAgents input argument was of unexpected type {0}", request["uuids"].GetType().ToString());
225 return FailureResult();
226 }
227
228 userIDs = ((List<string>)request["uuids"]).ToArray();
229
230 PresenceInfo[] pinfos = m_PresenceService.GetAgents(userIDs);
231
232 Dictionary<string, object> result = new Dictionary<string, object>();
233 if ((pinfos == null) || ((pinfos != null) && (pinfos.Length == 0)))
234 result["result"] = "null";
235 else
236 {
237 int i = 0;
238 foreach (PresenceInfo pinfo in pinfos)
239 {
240 Dictionary<string, object> rinfoDict = pinfo.ToKeyValuePairs();
241 result["presence" + i] = rinfoDict;
242 i++;
243 }
244 }
245
246 string xmlString = ServerUtils.BuildXmlResponse(result);
247 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
248 UTF8Encoding encoding = new UTF8Encoding();
249 return encoding.GetBytes(xmlString);
250 }
251
252
117 private byte[] SuccessResult() 253 private byte[] SuccessResult()
118 { 254 {
119 XmlDocument doc = new XmlDocument(); 255 XmlDocument doc = new XmlDocument();