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.cs84
1 files changed, 83 insertions, 1 deletions
diff --git a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
index 0e8ce80..7a9fb4b 100644
--- a/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs
@@ -54,13 +54,19 @@ namespace OpenSim.Server.Handlers.Hypergrid
54 private IUserAgentService m_HomeUsersService; 54 private IUserAgentService m_HomeUsersService;
55 55
56 public UserAgentServerConnector(IConfigSource config, IHttpServer server) : 56 public UserAgentServerConnector(IConfigSource config, IHttpServer server) :
57 this(config, server, null)
58 {
59 }
60
61 public UserAgentServerConnector(IConfigSource config, IHttpServer server, IFriendsSimConnector friendsConnector) :
57 base(config, server, String.Empty) 62 base(config, server, String.Empty)
58 { 63 {
59 IConfig gridConfig = config.Configs["UserAgentService"]; 64 IConfig gridConfig = config.Configs["UserAgentService"];
60 if (gridConfig != null) 65 if (gridConfig != null)
61 { 66 {
62 string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty); 67 string serviceDll = gridConfig.GetString("LocalServiceModule", string.Empty);
63 Object[] args = new Object[] { config }; 68
69 Object[] args = new Object[] { config, friendsConnector };
64 m_HomeUsersService = ServerUtils.LoadPlugin<IUserAgentService>(serviceDll, args); 70 m_HomeUsersService = ServerUtils.LoadPlugin<IUserAgentService>(serviceDll, args);
65 } 71 }
66 if (m_HomeUsersService == null) 72 if (m_HomeUsersService == null)
@@ -75,6 +81,9 @@ namespace OpenSim.Server.Handlers.Hypergrid
75 server.AddXmlRPCHandler("verify_client", VerifyClient, false); 81 server.AddXmlRPCHandler("verify_client", VerifyClient, false);
76 server.AddXmlRPCHandler("logout_agent", LogoutAgent, false); 82 server.AddXmlRPCHandler("logout_agent", LogoutAgent, false);
77 83
84 server.AddXmlRPCHandler("status_notification", StatusNotification, false);
85 server.AddXmlRPCHandler("get_online_friends", GetOnlineFriends, false);
86
78 server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService, loginServerIP, proxy).Handler); 87 server.AddHTTPHandler("/homeagent/", new HomeAgentHandler(m_HomeUsersService, loginServerIP, proxy).Handler);
79 } 88 }
80 89
@@ -194,5 +203,78 @@ namespace OpenSim.Server.Handlers.Hypergrid
194 203
195 } 204 }
196 205
206 public XmlRpcResponse StatusNotification(XmlRpcRequest request, IPEndPoint remoteClient)
207 {
208 Hashtable hash = new Hashtable();
209 hash["result"] = "false";
210
211 Hashtable requestData = (Hashtable)request.Params[0];
212 //string host = (string)requestData["host"];
213 //string portstr = (string)requestData["port"];
214 if (requestData.ContainsKey("userID") && requestData.ContainsKey("online"))
215 {
216 string userID_str = (string)requestData["userID"];
217 UUID userID = UUID.Zero;
218 UUID.TryParse(userID_str, out userID);
219 List<string> ids = new List<string>();
220 foreach (object key in requestData.Keys)
221 {
222 if (key is string && ((string)key).StartsWith("friend_") && requestData[key] != null)
223 ids.Add(requestData[key].ToString());
224 }
225 bool online = false;
226 bool.TryParse(requestData["online"].ToString(), out online);
227
228 hash["result"] = "true";
229
230 // let's spawn a thread for this, because it may take a long time...
231 Util.FireAndForget(delegate { m_HomeUsersService.StatusNotification(ids, userID, online); });
232 }
233
234 XmlRpcResponse response = new XmlRpcResponse();
235 response.Value = hash;
236 return response;
237
238 }
239
240 public XmlRpcResponse GetOnlineFriends(XmlRpcRequest request, IPEndPoint remoteClient)
241 {
242 Hashtable hash = new Hashtable();
243
244 Hashtable requestData = (Hashtable)request.Params[0];
245 //string host = (string)requestData["host"];
246 //string portstr = (string)requestData["port"];
247 if (requestData.ContainsKey("userID"))
248 {
249 string userID_str = (string)requestData["userID"];
250 UUID userID = UUID.Zero;
251 UUID.TryParse(userID_str, out userID);
252 List<string> ids = new List<string>();
253 foreach (object key in requestData.Keys)
254 {
255 if (key is string && ((string)key).StartsWith("friend_") && requestData[key] != null)
256 ids.Add(requestData[key].ToString());
257 }
258
259 // let's spawn a thread for this, because it may take a long time...
260 List<UUID> online = m_HomeUsersService.GetOnlineFriends(userID, ids);
261 if (online.Count > 0)
262 {
263 int i = 0;
264 foreach (UUID id in online)
265 {
266 hash["friend_" + i.ToString()] = id.ToString();
267 i++;
268 }
269
270 }
271 }
272
273 XmlRpcResponse response = new XmlRpcResponse();
274 response.Value = hash;
275 return response;
276
277 }
278
197 } 279 }
198} 280}