aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer.Modules/UserManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/UserServer.Modules/UserManager.cs')
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserManager.cs686
1 files changed, 686 insertions, 0 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/UserManager.cs b/OpenSim/Grid/UserServer.Modules/UserManager.cs
new file mode 100644
index 0000000..dd9f495
--- /dev/null
+++ b/OpenSim/Grid/UserServer.Modules/UserManager.cs
@@ -0,0 +1,686 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using log4net;
33using Nwc.XmlRpc;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Communications;
37using OpenSim.Framework.Servers;
38
39namespace OpenSim.Grid.UserServer.Modules
40{
41 public delegate void logOffUser(UUID AgentID);
42
43 public class UserManager
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 public event logOffUser OnLogOffUser;
48 private logOffUser handlerLogOffUser;
49
50 private UserDataBaseService m_userDataBaseService;
51 private BaseHttpServer m_httpServer;
52
53 /// <summary>
54 ///
55 /// </summary>
56 /// <param name="userDataBaseService"></param>
57 public UserManager( UserDataBaseService userDataBaseService)
58 {
59 m_userDataBaseService = userDataBaseService;
60 }
61
62 public void Initialise()
63 {
64
65 }
66
67 public void PostInitialise()
68 {
69
70 }
71
72 public void RegisterHandlers(BaseHttpServer httpServer)
73 {
74 m_httpServer = httpServer;
75
76 m_httpServer.AddXmlRPCHandler("get_user_by_name", XmlRPCGetUserMethodName);
77 m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID);
78 m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar);
79
80 m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion);
81 m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID);
82 m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID);
83 m_httpServer.AddXmlRPCHandler("check_auth_session", XmlRPCCheckAuthSession);
84
85 m_httpServer.AddXmlRPCHandler("update_user_profile", XmlRpcResponseXmlRPCUpdateUserProfile);
86
87 m_httpServer.AddStreamHandler(new RestStreamHandler("DELETE", "/usersessions/", RestDeleteUserSessionMethod));
88 }
89
90 /// <summary>
91 /// Deletes an active agent session
92 /// </summary>
93 /// <param name="request">The request</param>
94 /// <param name="path">The path (eg /bork/narf/test)</param>
95 /// <param name="param">Parameters sent</param>
96 /// <param name="httpRequest">HTTP request header object</param>
97 /// <param name="httpResponse">HTTP response header object</param>
98 /// <returns>Success "OK" else error</returns>
99 public string RestDeleteUserSessionMethod(string request, string path, string param,
100 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
101 {
102 // TODO! Important!
103
104 return "OK";
105 }
106
107 /// <summary>
108 /// Returns an error message that the user could not be found in the database
109 /// </summary>
110 /// <returns>XML string consisting of a error element containing individual error(s)</returns>
111 public XmlRpcResponse CreateUnknownUserErrorResponse()
112 {
113 XmlRpcResponse response = new XmlRpcResponse();
114 Hashtable responseData = new Hashtable();
115 responseData["error_type"] = "unknown_user";
116 responseData["error_desc"] = "The user requested is not in the database";
117
118 response.Value = responseData;
119 return response;
120 }
121
122 public XmlRpcResponse AvatarPickerListtoXmlRPCResponse(UUID queryID, List<AvatarPickerAvatar> returnUsers)
123 {
124 XmlRpcResponse response = new XmlRpcResponse();
125 Hashtable responseData = new Hashtable();
126 // Query Result Information
127 responseData["queryid"] = queryID.ToString();
128 responseData["avcount"] = returnUsers.Count.ToString();
129
130 for (int i = 0; i < returnUsers.Count; i++)
131 {
132 responseData["avatarid" + i] = returnUsers[i].AvatarID.ToString();
133 responseData["firstname" + i] = returnUsers[i].firstName;
134 responseData["lastname" + i] = returnUsers[i].lastName;
135 }
136 response.Value = responseData;
137
138 return response;
139 }
140
141 /// <summary>
142 /// Converts a user profile to an XML element which can be returned
143 /// </summary>
144 /// <param name="profile">The user profile</param>
145 /// <returns>A string containing an XML Document of the user profile</returns>
146 public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile)
147 {
148 XmlRpcResponse response = new XmlRpcResponse();
149 Hashtable responseData = new Hashtable();
150
151 // Account information
152 responseData["firstname"] = profile.FirstName;
153 responseData["lastname"] = profile.SurName;
154 responseData["uuid"] = profile.ID.ToString();
155 // Server Information
156 responseData["server_inventory"] = profile.UserInventoryURI;
157 responseData["server_asset"] = profile.UserAssetURI;
158 // Profile Information
159 responseData["profile_about"] = profile.AboutText;
160 responseData["profile_firstlife_about"] = profile.FirstLifeAboutText;
161 responseData["profile_firstlife_image"] = profile.FirstLifeImage.ToString();
162 responseData["profile_can_do"] = profile.CanDoMask.ToString();
163 responseData["profile_want_do"] = profile.WantDoMask.ToString();
164 responseData["profile_image"] = profile.Image.ToString();
165 responseData["profile_created"] = profile.Created.ToString();
166 responseData["profile_lastlogin"] = profile.LastLogin.ToString();
167 // Home region information
168 responseData["home_coordinates_x"] = profile.HomeLocation.X.ToString();
169 responseData["home_coordinates_y"] = profile.HomeLocation.Y.ToString();
170 responseData["home_coordinates_z"] = profile.HomeLocation.Z.ToString();
171
172 responseData["home_region"] = profile.HomeRegion.ToString();
173 responseData["home_region_id"] = profile.HomeRegionID.ToString();
174
175 responseData["home_look_x"] = profile.HomeLookAt.X.ToString();
176 responseData["home_look_y"] = profile.HomeLookAt.Y.ToString();
177 responseData["home_look_z"] = profile.HomeLookAt.Z.ToString();
178
179 responseData["user_flags"] = profile.UserFlags.ToString();
180 responseData["god_level"] = profile.GodLevel.ToString();
181 responseData["custom_type"] = profile.CustomType;
182 responseData["partner"] = profile.Partner.ToString();
183 response.Value = responseData;
184
185 return response;
186 }
187
188 #region XMLRPC User Methods
189
190 public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request)
191 {
192 // XmlRpcResponse response = new XmlRpcResponse();
193 Hashtable requestData = (Hashtable) request.Params[0];
194 List<AvatarPickerAvatar> returnAvatar = new List<AvatarPickerAvatar>();
195 UUID queryID = new UUID(UUID.Zero.ToString());
196
197 if (requestData.Contains("avquery") && requestData.Contains("queryid"))
198 {
199 queryID = new UUID((string) requestData["queryid"]);
200 returnAvatar = m_userDataBaseService.GenerateAgentPickerRequestResponse(queryID, (string) requestData["avquery"]);
201 }
202
203 m_log.InfoFormat("[AVATARINFO]: Servicing Avatar Query: " + (string) requestData["avquery"]);
204 return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar);
205 }
206
207 public XmlRpcResponse XmlRPCAtRegion(XmlRpcRequest request)
208 {
209 XmlRpcResponse response = new XmlRpcResponse();
210 Hashtable requestData = (Hashtable) request.Params[0];
211 Hashtable responseData = new Hashtable();
212 string returnstring = "FALSE";
213
214 if (requestData.Contains("avatar_id") && requestData.Contains("region_handle") &&
215 requestData.Contains("region_uuid"))
216 {
217 // ulong cregionhandle = 0;
218 UUID regionUUID;
219 UUID avatarUUID;
220
221 UUID.TryParse((string) requestData["avatar_id"], out avatarUUID);
222 UUID.TryParse((string) requestData["region_uuid"], out regionUUID);
223
224 if (avatarUUID != UUID.Zero)
225 {
226 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(avatarUUID);
227 userProfile.CurrentAgent.Region = regionUUID;
228 userProfile.CurrentAgent.Handle = (ulong) Convert.ToInt64((string) requestData["region_handle"]);
229 //userProfile.CurrentAgent.
230 m_userDataBaseService.CommitAgent(ref userProfile);
231 //setUserProfile(userProfile);
232
233
234 returnstring = "TRUE";
235 }
236 }
237 responseData.Add("returnString", returnstring);
238 response.Value = responseData;
239 return response;
240 }
241
242 public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request)
243 {
244 // XmlRpcResponse response = new XmlRpcResponse();
245 Hashtable requestData = (Hashtable) request.Params[0];
246 UserProfileData userProfile;
247 if (requestData.Contains("avatar_name"))
248 {
249 string query = (string) requestData["avatar_name"];
250
251 // Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]");
252
253 string[] querysplit = query.Split(' ');
254
255 if (querysplit.Length == 2)
256 {
257 userProfile = m_userDataBaseService.GetUserProfile(querysplit[0], querysplit[1]);
258 if (userProfile == null)
259 {
260 return CreateUnknownUserErrorResponse();
261 }
262 }
263 else
264 {
265 return CreateUnknownUserErrorResponse();
266 }
267 }
268 else
269 {
270 return CreateUnknownUserErrorResponse();
271 }
272
273 return ProfileToXmlRPCResponse(userProfile);
274 }
275
276 public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request)
277 {
278 // XmlRpcResponse response = new XmlRpcResponse();
279 Hashtable requestData = (Hashtable) request.Params[0];
280 UserProfileData userProfile;
281 //CFK: this clogs the UserServer log and is not necessary at this time.
282 //CFK: m_log.Debug("METHOD BY UUID CALLED");
283 if (requestData.Contains("avatar_uuid"))
284 {
285 try
286 {
287 UUID guess = new UUID((string) requestData["avatar_uuid"]);
288
289 userProfile = m_userDataBaseService.GetUserProfile(guess);
290 }
291 catch (FormatException)
292 {
293 return CreateUnknownUserErrorResponse();
294 }
295
296 if (userProfile == null)
297 {
298 return CreateUnknownUserErrorResponse();
299 }
300 }
301 else
302 {
303 return CreateUnknownUserErrorResponse();
304 }
305
306 return ProfileToXmlRPCResponse(userProfile);
307 }
308
309 public XmlRpcResponse XmlRPCGetAgentMethodUUID(XmlRpcRequest request)
310 {
311 XmlRpcResponse response = new XmlRpcResponse();
312 Hashtable requestData = (Hashtable) request.Params[0];
313 UserProfileData userProfile;
314 //CFK: this clogs the UserServer log and is not necessary at this time.
315 //CFK: m_log.Debug("METHOD BY UUID CALLED");
316 if (requestData.Contains("avatar_uuid"))
317 {
318 UUID guess;
319
320 UUID.TryParse((string) requestData["avatar_uuid"], out guess);
321
322 if (guess == UUID.Zero)
323 {
324 return CreateUnknownUserErrorResponse();
325 }
326
327 userProfile = m_userDataBaseService.GetUserProfile(guess);
328
329 if (userProfile == null)
330 {
331 return CreateUnknownUserErrorResponse();
332 }
333
334 // no agent???
335 if (userProfile.CurrentAgent == null)
336 {
337 return CreateUnknownUserErrorResponse();
338 }
339 Hashtable responseData = new Hashtable();
340
341 responseData["handle"] = userProfile.CurrentAgent.Handle.ToString();
342 responseData["session"] = userProfile.CurrentAgent.SessionID.ToString();
343 if (userProfile.CurrentAgent.AgentOnline)
344 responseData["agent_online"] = "TRUE";
345 else
346 responseData["agent_online"] = "FALSE";
347
348 response.Value = responseData;
349 }
350 else
351 {
352 return CreateUnknownUserErrorResponse();
353 }
354
355 return response;
356 }
357
358 public XmlRpcResponse XmlRPCCheckAuthSession(XmlRpcRequest request)
359 {
360 XmlRpcResponse response = new XmlRpcResponse();
361 Hashtable requestData = (Hashtable) request.Params[0];
362 UserProfileData userProfile;
363
364 string authed = "FALSE";
365 if (requestData.Contains("avatar_uuid") && requestData.Contains("session_id"))
366 {
367 UUID guess_aid;
368 UUID guess_sid;
369
370 UUID.TryParse((string) requestData["avatar_uuid"], out guess_aid);
371 if (guess_aid == UUID.Zero)
372 {
373 return CreateUnknownUserErrorResponse();
374 }
375 UUID.TryParse((string) requestData["session_id"], out guess_sid);
376 if (guess_sid == UUID.Zero)
377 {
378 return CreateUnknownUserErrorResponse();
379 }
380 userProfile = m_userDataBaseService.GetUserProfile(guess_aid);
381 if (userProfile != null && userProfile.CurrentAgent != null &&
382 userProfile.CurrentAgent.SessionID == guess_sid)
383 {
384 authed = "TRUE";
385 }
386 m_log.InfoFormat("[UserManager]: CheckAuthSession TRUE for user {0}", guess_aid);
387 }
388 else
389 {
390 m_log.InfoFormat("[UserManager]: CheckAuthSession FALSE");
391 return CreateUnknownUserErrorResponse();
392 }
393 Hashtable responseData = new Hashtable();
394 responseData["auth_session"] = authed;
395 response.Value = responseData;
396 return response;
397 }
398
399 public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserProfile(XmlRpcRequest request)
400 {
401 m_log.Debug("[UserManager]: Got request to update user profile");
402 XmlRpcResponse response = new XmlRpcResponse();
403 Hashtable requestData = (Hashtable) request.Params[0];
404 Hashtable responseData = new Hashtable();
405
406 if (!requestData.Contains("avatar_uuid"))
407 {
408 return CreateUnknownUserErrorResponse();
409 }
410
411 UUID UserUUID = new UUID((string) requestData["avatar_uuid"]);
412 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(UserUUID);
413 if (null == userProfile)
414 {
415 return CreateUnknownUserErrorResponse();
416 }
417 // don't know how yet.
418 if (requestData.Contains("AllowPublish"))
419 {
420 }
421 if (requestData.Contains("FLImageID"))
422 {
423 userProfile.FirstLifeImage = new UUID((string) requestData["FLImageID"]);
424 }
425 if (requestData.Contains("ImageID"))
426 {
427 userProfile.Image = new UUID((string) requestData["ImageID"]);
428 }
429 // dont' know how yet
430 if (requestData.Contains("MaturePublish"))
431 {
432 }
433 if (requestData.Contains("AboutText"))
434 {
435 userProfile.AboutText = (string) requestData["AboutText"];
436 }
437 if (requestData.Contains("FLAboutText"))
438 {
439 userProfile.FirstLifeAboutText = (string) requestData["FLAboutText"];
440 }
441 // not in DB yet.
442 if (requestData.Contains("ProfileURL"))
443 {
444 }
445 if (requestData.Contains("home_region"))
446 {
447 try
448 {
449 userProfile.HomeRegion = Convert.ToUInt64((string) requestData["home_region"]);
450 }
451 catch (ArgumentException)
452 {
453 m_log.Error("[PROFILE]:Failed to set home region, Invalid Argument");
454 }
455 catch (FormatException)
456 {
457 m_log.Error("[PROFILE]:Failed to set home region, Invalid Format");
458 }
459 catch (OverflowException)
460 {
461 m_log.Error("[PROFILE]:Failed to set home region, Value was too large");
462 }
463 }
464 if (requestData.Contains("home_region_id"))
465 {
466 UUID regionID;
467 UUID.TryParse((string) requestData["home_region_id"], out regionID);
468 userProfile.HomeRegionID = regionID;
469 }
470 if (requestData.Contains("home_pos_x"))
471 {
472 try
473 {
474 userProfile.HomeLocationX = (float) Convert.ToDecimal((string) requestData["home_pos_x"]);
475 }
476 catch (InvalidCastException)
477 {
478 m_log.Error("[PROFILE]:Failed to set home postion x");
479 }
480 }
481 if (requestData.Contains("home_pos_y"))
482 {
483 try
484 {
485 userProfile.HomeLocationY = (float) Convert.ToDecimal((string) requestData["home_pos_y"]);
486 }
487 catch (InvalidCastException)
488 {
489 m_log.Error("[PROFILE]:Failed to set home postion y");
490 }
491 }
492 if (requestData.Contains("home_pos_z"))
493 {
494 try
495 {
496 userProfile.HomeLocationZ = (float) Convert.ToDecimal((string) requestData["home_pos_z"]);
497 }
498 catch (InvalidCastException)
499 {
500 m_log.Error("[PROFILE]:Failed to set home postion z");
501 }
502 }
503 if (requestData.Contains("home_look_x"))
504 {
505 try
506 {
507 userProfile.HomeLookAtX = (float) Convert.ToDecimal((string) requestData["home_look_x"]);
508 }
509 catch (InvalidCastException)
510 {
511 m_log.Error("[PROFILE]:Failed to set home lookat x");
512 }
513 }
514 if (requestData.Contains("home_look_y"))
515 {
516 try
517 {
518 userProfile.HomeLookAtY = (float) Convert.ToDecimal((string) requestData["home_look_y"]);
519 }
520 catch (InvalidCastException)
521 {
522 m_log.Error("[PROFILE]:Failed to set home lookat y");
523 }
524 }
525 if (requestData.Contains("home_look_z"))
526 {
527 try
528 {
529 userProfile.HomeLookAtZ = (float) Convert.ToDecimal((string) requestData["home_look_z"]);
530 }
531 catch (InvalidCastException)
532 {
533 m_log.Error("[PROFILE]:Failed to set home lookat z");
534 }
535 }
536 if (requestData.Contains("user_flags"))
537 {
538 try
539 {
540 userProfile.UserFlags = Convert.ToInt32((string) requestData["user_flags"]);
541 }
542 catch (InvalidCastException)
543 {
544 m_log.Error("[PROFILE]:Failed to set user flags");
545 }
546 }
547 if (requestData.Contains("god_level"))
548 {
549 try
550 {
551 userProfile.GodLevel = Convert.ToInt32((string) requestData["god_level"]);
552 }
553 catch (InvalidCastException)
554 {
555 m_log.Error("[PROFILE]:Failed to set god level");
556 }
557 }
558 if (requestData.Contains("custom_type"))
559 {
560 try
561 {
562 userProfile.CustomType = (string) requestData["custom_type"];
563 }
564 catch (InvalidCastException)
565 {
566 m_log.Error("[PROFILE]:Failed to set custom type");
567 }
568 }
569 if (requestData.Contains("partner"))
570 {
571 try
572 {
573 userProfile.Partner = new UUID((string) requestData["partner"]);
574 }
575 catch (InvalidCastException)
576 {
577 m_log.Error("[PROFILE]:Failed to set partner");
578 }
579 }
580 else
581 {
582 userProfile.Partner = UUID.Zero;
583 }
584
585 // call plugin!
586 bool ret = m_userDataBaseService.UpdateUserProfile(userProfile);
587 responseData["returnString"] = ret.ToString();
588 response.Value = responseData;
589 return response;
590 }
591
592 public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request)
593 {
594 XmlRpcResponse response = new XmlRpcResponse();
595 Hashtable requestData = (Hashtable) request.Params[0];
596
597 if (requestData.Contains("avatar_uuid"))
598 {
599 try
600 {
601 UUID userUUID = new UUID((string)requestData["avatar_uuid"]);
602 UUID RegionID = new UUID((string)requestData["region_uuid"]);
603 ulong regionhandle = (ulong)Convert.ToInt64((string)requestData["region_handle"]);
604 Vector3 position = new Vector3(
605 (float)Convert.ToDecimal((string)requestData["region_pos_x"]),
606 (float)Convert.ToDecimal((string)requestData["region_pos_y"]),
607 (float)Convert.ToDecimal((string)requestData["region_pos_z"]));
608 Vector3 lookat = new Vector3(
609 (float)Convert.ToDecimal((string)requestData["lookat_x"]),
610 (float)Convert.ToDecimal((string)requestData["lookat_y"]),
611 (float)Convert.ToDecimal((string)requestData["lookat_z"]));
612
613 handlerLogOffUser = OnLogOffUser;
614 if (handlerLogOffUser != null)
615 handlerLogOffUser(userUUID);
616
617 m_userDataBaseService.LogOffUser(userUUID, RegionID, regionhandle, position, lookat);
618 }
619 catch (FormatException)
620 {
621 m_log.Warn("[LOGOUT]: Error in Logout XMLRPC Params");
622 return response;
623 }
624 }
625 else
626 {
627 return CreateUnknownUserErrorResponse();
628 }
629
630 return response;
631 }
632
633 #endregion
634
635
636 public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle)
637 {
638 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID);
639 if (userProfile != null)
640 {
641 userProfile.CurrentAgent.Region = regionID;
642 userProfile.CurrentAgent.Handle = regionHandle;
643 m_userDataBaseService.CommitAgent(ref userProfile);
644 }
645 }
646
647 public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
648 {
649 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID);
650 if (userProfile != null)
651 {
652 if (userProfile.CurrentAgent.Region == regionID)
653 {
654 UserAgentData userAgent = userProfile.CurrentAgent;
655 if (userAgent != null && userAgent.AgentOnline)
656 {
657 userAgent.AgentOnline = false;
658 userAgent.LogoutTime = Util.UnixTimeSinceEpoch();
659 if (regionID != UUID.Zero)
660 {
661 userAgent.Region = regionID;
662 }
663 userAgent.Handle = regionHandle;
664 userProfile.LastLogin = userAgent.LogoutTime;
665
666 m_userDataBaseService.CommitAgent(ref userProfile);
667
668 handlerLogOffUser = OnLogOffUser;
669 if (handlerLogOffUser != null)
670 handlerLogOffUser(agentID);
671 }
672 }
673 }
674 }
675
676 public void HandleRegionStartup(UUID regionID)
677 {
678 m_userDataBaseService.LogoutUsers(regionID);
679 }
680
681 public void HandleRegionShutdown(UUID regionID)
682 {
683 m_userDataBaseService.LogoutUsers(regionID);
684 }
685 }
686}