aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers
diff options
context:
space:
mode:
authorDiva Canto2011-05-23 19:45:39 -0700
committerDiva Canto2011-05-23 19:45:39 -0700
commit24f28d353427d1905ae1a46408841265379e29c3 (patch)
tree07234a5837632bbe0d1198bf282d023c9cd1fb43 /OpenSim/Server/Handlers
parentMore on HG Friends. Added Delete(string, string) across the board. Added secu... (diff)
downloadopensim-SC_OLD-24f28d353427d1905ae1a46408841265379e29c3.zip
opensim-SC_OLD-24f28d353427d1905ae1a46408841265379e29c3.tar.gz
opensim-SC_OLD-24f28d353427d1905ae1a46408841265379e29c3.tar.bz2
opensim-SC_OLD-24f28d353427d1905ae1a46408841265379e29c3.tar.xz
HG friends: Status notifications working. Also initial logins get the online friends in other grids.
Diffstat (limited to 'OpenSim/Server/Handlers')
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs4
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/UserAgentServerConnector.cs84
2 files changed, 87 insertions, 1 deletions
diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
index a83d0e8..841811e 100644
--- a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
@@ -140,16 +140,20 @@ namespace OpenSim.Server.Handlers.Hypergrid
140 140
141 byte[] NewFriendship(Dictionary<string, object> request) 141 byte[] NewFriendship(Dictionary<string, object> request)
142 { 142 {
143 m_log.DebugFormat("[XXX] 1");
143 if (!VerifyServiceKey(request)) 144 if (!VerifyServiceKey(request))
144 return FailureResult(); 145 return FailureResult();
145 146
147 m_log.DebugFormat("[XXX] 2");
146 // OK, can proceed 148 // OK, can proceed
147 FriendInfo friend = new FriendInfo(request); 149 FriendInfo friend = new FriendInfo(request);
148 UUID friendID; 150 UUID friendID;
149 string tmp = string.Empty; 151 string tmp = string.Empty;
152 m_log.DebugFormat("[XXX] 3");
150 if (!Util.ParseUniversalUserIdentifier(friend.Friend, out friendID, out tmp, out tmp, out tmp, out tmp)) 153 if (!Util.ParseUniversalUserIdentifier(friend.Friend, out friendID, out tmp, out tmp, out tmp, out tmp))
151 return FailureResult(); 154 return FailureResult();
152 155
156
153 m_log.DebugFormat("[HGFRIENDS HANDLER]: New friendship {0} {1}", friend.PrincipalID, friend.Friend); 157 m_log.DebugFormat("[HGFRIENDS HANDLER]: New friendship {0} {1}", friend.PrincipalID, friend.Friend);
154 158
155 // If the friendship already exists, return fail 159 // If the friendship already exists, return fail
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}