From a3851b3812aae6221714b1e61656d0853fce7124 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 20 Jan 2008 23:08:50 +0000 Subject: [PATCH] * Added hooks for logout to all IUserService and all that implement it. * Added a Logout message with a name on the console * Added a *fixme* message to figure out why the current agent session is null * After updating you may notice that there's a login and also a logout --- .../Communications/CommunicationsManager.cs | 13 +++++++ .../Communications/UserManagerBase.cs | 37 +++++++++++++++++++ OpenSim/Framework/Data.DB4o/DB4oUserData.cs | 5 +-- OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs | 5 +-- OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 4 -- .../Framework/Data.SQLite/SQLiteRegionData.cs | 6 +-- .../Framework/Data.SQLite/SQLiteUserData.cs | 4 -- OpenSim/Framework/IUserData.cs | 6 --- OpenSim/Framework/IUserService.cs | 10 +++++ .../Grid/MessagingServer/MessageService.cs | 2 +- OpenSim/Grid/UserServer/Main.cs | 1 + OpenSim/Grid/UserServer/UserManager.cs | 37 +++++++++++++++++++ .../Communications/OGS1/OGS1GridServices.cs | 3 ++ .../Communications/OGS1/OGS1UserServices.cs | 26 ++++++++++++- OpenSim/Region/Environment/Scenes/Scene.cs | 3 ++ 15 files changed, 135 insertions(+), 27 deletions(-) diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index a07b1652ba..baf24f00dd 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -163,6 +163,19 @@ namespace OpenSim.Framework.Communications { m_userService.AddNewUserFriend(friendlistowner, friend, perms); } + /// + /// Logs off a user and does the appropriate communications + /// + /// + /// + /// + /// + /// + /// + public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz) + { + m_userService.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); + } /// /// Delete friend on friendlistowner's friendlist. diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index 42165533cb..8821776649 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -411,7 +411,44 @@ namespace OpenSim.Framework.UserManagement profile.currentAgent = agent; } + public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz) + { + UserProfileData userProfile; + UserAgentData userAgent; + LLVector3 currentPos = new LLVector3(posx, posy, posz); + userProfile = GetUserProfile(userid); + + if (userProfile != null) + { + + userAgent = userProfile.currentAgent; + if (userAgent != null) + { + userAgent.agentOnline = false; + userAgent.logoutTime = Util.UnixTimeSinceEpoch(); + userAgent.sessionID = LLUUID.Zero; + userAgent.currentRegion = regionid; + userAgent.currentHandle = regionhandle; + + userAgent.currentPos = currentPos; + + userProfile.currentAgent = userAgent; + + + CommitAgent(ref userProfile); + } + else + { + MainLog.Instance.Verbose("LOGOUT", "didn't save logout position, currentAgent is null *do Fix "); + } + MainLog.Instance.Verbose("LOGOUT", userProfile.username + " " + userProfile.surname); + } + else + { + MainLog.Instance.Warn("LOGOUT", "Unknown User logged out"); + } + } public void CreateAgent(UserProfileData profile, LLSD request) { UserAgentData agent = new UserAgentData(); diff --git a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs index 47521e499d..6059cbea76 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs @@ -169,10 +169,7 @@ namespace OpenSim.Framework.Data.DB4o //MainLog.Instance.Verbose("USER", "Stub UpdateUserCUrrentRegion called"); } - public void LogOffUser(LLUUID avatarid) - { - //MainLog.Instance.Verbose("USER", "Stub LogOffUser called"); - } + public List GeneratePickerResults(LLUUID queryID, string query) { diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs index 429ed394cc..aa0526c27d 100644 --- a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs +++ b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs @@ -129,10 +129,7 @@ namespace OpenSim.Framework.Data.MSSQL MainLog.Instance.Verbose("USER", "Stub UpdateUserCUrrentRegion called"); } - public void LogOffUser(LLUUID avatarid) - { - MainLog.Instance.Verbose("USER", "Stub LogOffUser called"); - } + public List GeneratePickerResults(LLUUID queryID, string query) { diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index f637db6e76..2ee20e08ef 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs @@ -331,10 +331,6 @@ namespace OpenSim.Framework.Data.MySQL MainLog.Instance.Verbose("USER", "Stub UpdateUserCUrrentRegion called"); } - public void LogOffUser(LLUUID avatarid) - { - MainLog.Instance.Verbose("USER", "Stub LogOffUser called"); - } public List GeneratePickerResults(LLUUID queryID, string query) { diff --git a/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs b/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs index 1364d3ea2d..2e22f000e8 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs @@ -188,9 +188,9 @@ namespace OpenSim.Framework.Data.SQLite } else if (prim.Stopped) { - MainLog.Instance.Verbose("DATASTORE", - "Adding stopped obj: " + obj.UUID + " to region: " + regionUUID); - addPrim(prim, Util.ToRawUuidString(obj.UUID), Util.ToRawUuidString(regionUUID)); + //MainLog.Instance.Verbose("DATASTORE", + //"Adding stopped obj: " + obj.UUID + " to region: " + regionUUID); + //addPrim(prim, Util.ToRawUuidString(obj.UUID), Util.ToRawUuidString(regionUUID)); } else { diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs index ed8275e777..ac7340ddc6 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs @@ -234,10 +234,6 @@ namespace OpenSim.Framework.Data.SQLite MainLog.Instance.Verbose("USER", "Stub UpdateUserCUrrentRegion called"); } - public void LogOffUser(LLUUID avatarid) - { - MainLog.Instance.Verbose("USER", "Stub LogOffUser called"); - } public List GeneratePickerResults(LLUUID queryID, string query) { diff --git a/OpenSim/Framework/IUserData.cs b/OpenSim/Framework/IUserData.cs index 9fd6fa815e..45ba7fa117 100644 --- a/OpenSim/Framework/IUserData.cs +++ b/OpenSim/Framework/IUserData.cs @@ -105,12 +105,6 @@ namespace OpenSim.Framework /// User Region the Avatar is IN void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid); - /// - /// Log User Off - /// - /// avatar to log off - void LogOffUser(LLUUID avatarid); - /// /// Adds a new agent to the database /// diff --git a/OpenSim/Framework/IUserService.cs b/OpenSim/Framework/IUserService.cs index 2b59c25ba2..f1f3c81438 100644 --- a/OpenSim/Framework/IUserService.cs +++ b/OpenSim/Framework/IUserService.cs @@ -72,6 +72,16 @@ namespace OpenSim.Framework /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms); + /// + /// Logs off a user on the user server + /// + /// UUID of the user + /// UUID of the Region + /// final position x + /// final position y + /// final position z + void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz); + /// /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for LLUUID friendslistowner /// diff --git a/OpenSim/Grid/MessagingServer/MessageService.cs b/OpenSim/Grid/MessagingServer/MessageService.cs index 01bd9aff86..056bfcb1c2 100644 --- a/OpenSim/Grid/MessagingServer/MessageService.cs +++ b/OpenSim/Grid/MessagingServer/MessageService.cs @@ -388,7 +388,7 @@ namespace OpenSim.Grid.MessagingServer LLUUID AgentID = new LLUUID((string)requestData["agent_id"]); - ProcessLogOff(AgentID); + //ProcessLogOff(AgentID); return new XmlRpcResponse(); diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 00a1641178..a2881e6734 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -115,6 +115,7 @@ namespace OpenSim.Grid.UserServer httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend); httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms); httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList); + httpServer.AddXmlRPCHandler("logout_of_simulator", m_userManager.XmlRPCLogOffUserMethodUUID); // Message Server ---> User Server httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer); diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index 03b1fbc242..3f2aa5b91a 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs @@ -317,6 +317,43 @@ namespace OpenSim.Grid.UserServer return ProfileToXmlRPCResponse(userProfile); } + public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + + + UserProfileData userProfile; + + if (requestData.Contains("avatar_uuid")) + { + try + { + LLUUID userUUID = new LLUUID((string)requestData["avatar_uuid"]); + LLUUID RegionID = new LLUUID((string)requestData["region_uuid"]); + ulong regionhandle = (ulong)Convert.ToInt64((string)requestData["region_handle"]); + float posx = (float)Convert.ToDecimal((string)requestData["region_pos_x"]); + float posy = (float)Convert.ToDecimal((string)requestData["region_pos_y"]); + float posz = (float)Convert.ToDecimal((string)requestData["region_pos_z"]); + + LogOffUser(userUUID, RegionID, regionhandle, posx, posy, posz); + } + catch (FormatException) + { + OpenSim.Framework.Console.MainLog.Instance.Warn("LOGOUT", "Error in Logout XMLRPC Params"); + return response; + } + + } + else + { + return CreateUnknownUserErrorResponse(); + } + + + return response; + } + #endregion public override UserProfileData SetupMasterUser(string firstName, string lastName) diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 7cd77db9a8..2ca9022c7b 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -375,6 +375,9 @@ namespace OpenSim.Region.Communications.OGS1 return neighbours; } + + + /// /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates /// diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index 36ab4bb883..2cf3665aa9 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -130,7 +130,31 @@ namespace OpenSim.Region.Communications.OGS1 return buddylist; } - + + /// + /// Logs off a user on the user server + /// + /// UUID of the user + /// UUID of the Region + /// final position x + /// final position y + /// final position z + public void LogOffUser(LLUUID userid, LLUUID regionid, ulong regionhandle, float posx, float posy, float posz) + { + Hashtable param = new Hashtable(); + param["avatar_uuid"] = userid.UUID.ToString(); + param["region_uuid"] = regionid.UUID.ToString(); + param["region_handle"] = regionhandle.ToString(); + param["region_pos_x"] = posx.ToString(); + param["region_pos_y"] = posy.ToString(); + param["region_pos_z"] = posz.ToString(); + + IList parameters = new ArrayList(); + parameters.Add(param); + XmlRpcRequest req = new XmlRpcRequest("logout_of_simulator", parameters); + XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000); + + } public UserProfileData GetUserProfile(string firstName, string lastName) { return GetUserProfile(firstName + " " + lastName); diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 76f6c602c4..2f961c1488 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1285,6 +1285,9 @@ namespace OpenSim.Region.Environment.Scenes else { m_innerScene.removeUserCount(true); + CommsManager.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, + avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, + avatar.AbsolutePosition.Z); } } catch (NullReferenceException)