aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid
diff options
context:
space:
mode:
authorTeravus Ovares2008-05-31 12:18:29 +0000
committerTeravus Ovares2008-05-31 12:18:29 +0000
commitfebe78d06249cd4d36a86e97610dd45ab518a757 (patch)
tree7b9733fc14045f09e874440b923cfe443b781b6a /OpenSim/Grid
parentMantis#1425. Thank you kindly, Melanie for a patch that: (diff)
downloadopensim-SC-febe78d06249cd4d36a86e97610dd45ab518a757.zip
opensim-SC-febe78d06249cd4d36a86e97610dd45ab518a757.tar.gz
opensim-SC-febe78d06249cd4d36a86e97610dd45ab518a757.tar.bz2
opensim-SC-febe78d06249cd4d36a86e97610dd45ab518a757.tar.xz
* Implements UserServer logoff in a few situations
* User tries to log-in but is already logged in. Userserver will send message to simulator user was in to log the user out there. * From the UserServer, admin types 'logoff-user firstname lastname message'. * Some regions may not get the message because they're not updated yet.
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/UserServer/Main.cs63
-rw-r--r--OpenSim/Grid/UserServer/UserLoginService.cs59
-rw-r--r--OpenSim/Grid/UserServer/UserManager.cs48
3 files changed, 170 insertions, 0 deletions
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 810c24e..9d7421c 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -129,6 +129,7 @@ namespace OpenSim.Grid.UserServer
129 m_httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList); 129 m_httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList);
130 m_httpServer.AddXmlRPCHandler("get_avatar_appearance", m_userManager.XmlRPCGetAvatarAppearance); 130 m_httpServer.AddXmlRPCHandler("get_avatar_appearance", m_userManager.XmlRPCGetAvatarAppearance);
131 m_httpServer.AddXmlRPCHandler("update_avatar_appearance", m_userManager.XmlRPCUpdateAvatarAppearance); 131 m_httpServer.AddXmlRPCHandler("update_avatar_appearance", m_userManager.XmlRPCUpdateAvatarAppearance);
132 m_httpServer.AddXmlRPCHandler("update_user_current_region", m_userManager.XmlRPCAtRegion);
132 m_httpServer.AddXmlRPCHandler("logout_of_simulator", m_userManager.XmlRPCLogOffUserMethodUUID); 133 m_httpServer.AddXmlRPCHandler("logout_of_simulator", m_userManager.XmlRPCLogOffUserMethodUUID);
133 134
134 // Message Server ---> User Server 135 // Message Server ---> User Server
@@ -221,6 +222,7 @@ namespace OpenSim.Grid.UserServer
221 { 222 {
222 case "help": 223 case "help":
223 m_console.Notice("create user - create a new user"); 224 m_console.Notice("create user - create a new user");
225 m_console.Notice("logoff-user <firstname> <lastname> <message> - logs off the specified user from the grid");
224 break; 226 break;
225 227
226 case "create": 228 case "create":
@@ -238,6 +240,67 @@ namespace OpenSim.Grid.UserServer
238 "RootFolders/", 240 "RootFolders/",
239 m_lastCreatedUser); 241 m_lastCreatedUser);
240 break; 242 break;
243 case "logoff-user":
244
245 if (cmdparams.Length >= 3)
246 {
247 string firstname = cmdparams[0];
248 string lastname = cmdparams[1];
249 string message = "";
250
251 for (int i = 2; i < cmdparams.Length; i++)
252 message += " " + cmdparams[i];
253
254 UserProfileData theUser = null;
255 try
256 {
257 theUser = m_loginService.GetTheUser(firstname, lastname);
258 }
259 catch (Exception)
260 {
261 m_log.Error("[LOGOFF]: Error getting user data from the database.");
262 }
263
264 if (theUser != null)
265 {
266 if (theUser.CurrentAgent != null)
267 {
268 if (theUser.CurrentAgent.AgentOnline)
269 {
270 m_log.Info("[LOGOFF]: Logging off requested user!");
271 m_loginService.LogOffUser(theUser, message);
272
273 theUser.CurrentAgent.AgentOnline = false;
274
275 m_loginService.CommitAgent(ref theUser);
276 }
277 else
278 {
279 m_log.Info("[LOGOFF]: User Doesn't appear to be online, sending the logoff message anyway.");
280 m_loginService.LogOffUser(theUser, message);
281
282 theUser.CurrentAgent.AgentOnline = false;
283
284 m_loginService.CommitAgent(ref theUser);
285 }
286 }
287 else
288 {
289 m_log.Error("[LOGOFF]: Unable to logoff-user. User doesn't have an agent record so I can't find the simulator to notify");
290 }
291
292 }
293 else
294 {
295 m_log.Info("[LOGOFF]: User doesn't exist in the database");
296 }
297 }
298 else
299 {
300 m_log.Error("[LOGOFF]: Invalid amount of parameters. logoff-user takes at least three. Firstname, Lastname, and message");
301 }
302
303 break;
241 } 304 }
242 } 305 }
243 306
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs
index 628c471..d538d36 100644
--- a/OpenSim/Grid/UserServer/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer/UserLoginService.cs
@@ -60,6 +60,65 @@ namespace OpenSim.Grid.UserServer
60 { 60 {
61 m_config = config; 61 m_config = config;
62 } 62 }
63 public override void LogOffUser(UserProfileData theUser, string message)
64 {
65 RegionProfileData SimInfo = null;
66 try
67 {
68 SimInfo = RegionProfileData.RequestSimProfileData(
69 theUser.CurrentAgent.Handle, m_config.GridServerURL,
70 m_config.GridSendKey, m_config.GridRecvKey);
71 if (SimInfo == null)
72 {
73 m_log.Error("[GRID]: Region user was in isn't currently logged in");
74 return;
75 }
76
77 }
78 catch (Exception)
79 {
80 m_log.Error("[GRID]: Unable to look up region to log user off");
81 return;
82 }
83 // Prepare notification
84 Hashtable SimParams = new Hashtable();
85 SimParams["agent_id"] = theUser.ID.ToString();
86 SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString();
87 //SimParams["region_secret"] = SimInfo.regionSecret;
88 //m_log.Info(SimInfo.regionSecret);
89 SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString();
90 SimParams["message"] = message;
91 ArrayList SendParams = new ArrayList();
92 SendParams.Add(SimParams);
93
94 // Update agent with target sim
95
96 m_log.InfoFormat(
97 "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}",
98 SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, theUser.FirstName + " " + theUser.SurName);
99 try
100 {
101 XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams);
102 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
103
104 if (GridResp.IsFault)
105 {
106 m_log.ErrorFormat(
107 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.",
108 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
109 }
110 }
111 catch (Exception)
112 {
113 m_log.Error("[LOGIN]: Error telling region to logout user!");
114 }
115
116 //base.LogOffUser(theUser);
117 }
118 //public override void LogOffUser(UserProfileData theUser)
119 //{
120
121 //}
63 122
64 /// <summary> 123 /// <summary>
65 /// Customises the login response and fills in missing values. 124 /// Customises the login response and fills in missing values.
diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs
index a82505d..1b47289 100644
--- a/OpenSim/Grid/UserServer/UserManager.cs
+++ b/OpenSim/Grid/UserServer/UserManager.cs
@@ -179,6 +179,54 @@ namespace OpenSim.Grid.UserServer
179 return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar); 179 return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar);
180 } 180 }
181 181
182 public XmlRpcResponse XmlRPCAtRegion(XmlRpcRequest request)
183 {
184 XmlRpcResponse response = new XmlRpcResponse();
185 Hashtable requestData = (Hashtable)request.Params[0];
186 Hashtable responseData = new Hashtable();
187 string returnstring = "FALSE";
188
189 if (requestData.Contains("avatar_id") && requestData.Contains("region_handle") && requestData.Contains("region_uuid"))
190 {
191 ulong cregionhandle = 0;
192 LLUUID regionUUID = LLUUID.Zero;
193 LLUUID AvatarID = LLUUID.Zero;
194
195 Helpers.TryParse((string)requestData["avatar_id"], out AvatarID);
196 Helpers.TryParse((string)requestData["region_uuid"], out regionUUID);
197 try
198 {
199 cregionhandle = (ulong)Convert.ToInt64((string)requestData["region_handle"]);
200 }
201 catch (ArgumentException)
202 {
203 }
204 catch (OverflowException)
205 {
206 }
207 catch (FormatException)
208 {
209 }
210
211 if (AvatarID != LLUUID.Zero)
212 {
213 UserProfileData userProfile = GetUserProfile(new LLUUID((string)requestData["avatar_id"]));
214 userProfile.CurrentAgent.Region = new LLUUID((string)requestData["region_uuid"]);
215 userProfile.CurrentAgent.Handle = (ulong)Convert.ToInt64((string)requestData["region_handle"]);
216 //userProfile.CurrentAgent.
217 CommitAgent(ref userProfile);
218 //setUserProfile(userProfile);
219
220
221 returnstring = "TRUE";
222 }
223
224 }
225 responseData.Add("returnString", returnstring);
226 response.Value = responseData;
227 return response;
228 }
229
182 public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request) 230 public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request)
183 { 231 {
184 XmlRpcResponse response = new XmlRpcResponse(); 232 XmlRpcResponse response = new XmlRpcResponse();