From febe78d06249cd4d36a86e97610dd45ab518a757 Mon Sep 17 00:00:00 2001
From: Teravus Ovares
Date: Sat, 31 May 2008 12:18:29 +0000
Subject: * 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.
---
.../Communications/Local/LocalBackEndServices.cs | 10 +++++++
.../Region/Communications/OGS1/OGS1GridServices.cs | 26 +++++++++++++++++
.../Region/Communications/OGS1/OGS1UserServices.cs | 30 +++++++++++++++++++
OpenSim/Region/Environment/Scenes/Scene.cs | 34 ++++++++++++++++++++--
.../Scenes/SceneCommunicationService.cs | 13 +++++++++
OpenSim/Region/Environment/Scenes/ScenePresence.cs | 1 +
6 files changed, 112 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
index 0203821..989f08a 100644
--- a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
+++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
@@ -419,6 +419,16 @@ namespace OpenSim.Region.Communications.Local
}
}
+ public void TriggerLogOffUser(ulong regionHandle, LLUUID agentID, LLUUID RegionSecret, string message)
+ {
+ if (m_regionListeners.ContainsKey(regionHandle))
+ {
+ //m_log.Info("[INTER]: " + rdebugRegionName + ":Local BackEnd: FoundLocalRegion To send it to: " + agent.firstname + " " + agent.lastname);
+
+ m_regionListeners[regionHandle].TriggerLogOffUser(regionHandle, agentID, RegionSecret, message);
+ }
+ }
+
public void TriggerExpectPrim(ulong regionHandle, LLUUID primID, string objData, int XMLMethod)
{
if (m_regionListeners.ContainsKey(regionHandle))
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
index 309a795..2e892c2 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs
@@ -86,6 +86,7 @@ namespace OpenSim.Region.Communications.OGS1
httpServer = httpServe;
//Respond to Grid Services requests
httpServer.AddXmlRPCHandler("expect_user", ExpectUser);
+ httpServer.AddXmlRPCHandler("logoff_user", LogOffUser);
httpServer.AddXmlRPCHandler("check", PingCheckReply);
StartRemoting();
@@ -603,6 +604,31 @@ namespace OpenSim.Region.Communications.OGS1
return new XmlRpcResponse();
}
+ // Grid Request Processing
+ ///
+ /// Ooops, our Agent must be dead if we're getting this request!
+ ///
+ ///
+ ///
+ public XmlRpcResponse LogOffUser(XmlRpcRequest request)
+ {
+ m_log.Debug("[CONNECTION DEBUGGING]: LogOff User Called ");
+ Hashtable requestData = (Hashtable)request.Params[0];
+ string message = (string)requestData["message"];
+ LLUUID agentID = LLUUID.Zero;
+ LLUUID RegionSecret = LLUUID.Zero;
+ Helpers.TryParse((string)requestData["agent_id"], out agentID);
+ Helpers.TryParse((string)requestData["region_secret"], out RegionSecret);
+
+ ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
+
+
+ m_localBackend.TriggerLogOffUser(regionHandle, agentID, RegionSecret,message);
+
+
+
+ return new XmlRpcResponse();
+ }
#region m_interRegion Comms
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
index 8807eab..e0e17df 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -196,6 +196,36 @@ namespace OpenSim.Region.Communications.OGS1
return GetUserProfile(firstName + " " + lastName);
}
+ public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid, ulong regionhandle)
+ {
+ Hashtable param = new Hashtable();
+ param.Add("avatar_id", avatarid.ToString());
+ param.Add("region_uuid", regionuuid.ToString());
+ param.Add("region_handle", regionhandle.ToString());
+ IList parameters = new ArrayList();
+ parameters.Add(param);
+ XmlRpcRequest req = new XmlRpcRequest("update_user_current_region", parameters);
+ XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
+ Hashtable respData = (Hashtable)resp.Value;
+ if (respData.ContainsKey("returnString"))
+ {
+ if ((string)respData["returnString"] == "TRUE")
+ {
+ m_log.Info("[OSG1 USER SERVICES]: Successfully updated user record");
+ }
+ else
+ {
+ m_log.Error("[OSG1 USER SERVICES]: Error updating user record");
+ }
+ }
+ else
+ {
+ m_log.Warn("[OSG1 USER SERVICES]: Error updating user record, Grid server may not be updated.");
+ }
+
+
+ }
+
public List GenerateAgentPickerRequestResponse(LLUUID queryID, string query)
{
List pickerlist = new List();
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 6916c6d..c74dca4 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -2003,8 +2003,8 @@ namespace OpenSim.Region.Environment.Scenes
m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup;
m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
-
- m_sceneGridService.KillObject = SendKillObject;
+ m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
+ m_sceneGridService.KillObject += SendKillObject;
}
///
@@ -2012,6 +2012,8 @@ namespace OpenSim.Region.Environment.Scenes
///
public void UnRegisterReginWithComms()
{
+ m_sceneGridService.KillObject -= SendKillObject;
+ m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup;
m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -2064,6 +2066,34 @@ namespace OpenSim.Region.Environment.Scenes
}
}
+ protected void HandleLogOffUserFromGrid(ulong regionHandle, LLUUID AvatarID, LLUUID RegionSecret, string message)
+ {
+ if (RegionInfo.RegionHandle == regionHandle)
+ {
+ ScenePresence loggingOffUser = null;
+ loggingOffUser = GetScenePresence(AvatarID);
+ if (loggingOffUser != null)
+ {
+ if (RegionSecret == loggingOffUser.ControllingClient.SecureSessionId)
+ {
+ loggingOffUser.ControllingClient.Kick(message);
+ // Give them a second to receive the message!
+ System.Threading.Thread.Sleep(1000);
+ loggingOffUser.ControllingClient.Close(true);
+ }
+ else
+ {
+ m_log.Info("[USERLOGOFF]: System sending the LogOff user message failed to sucessfully authenticate");
+ }
+ }
+ else
+ {
+ m_log.InfoFormat("[USERLOGOFF]: Got a logoff request for {0} but the user isn't here. The user might already have been logged out", AvatarID.ToString());
+ }
+ }
+
+
+ }
///
/// Add a caps handler for the given agent. If the CAPS handler already exists for this agent,
/// then it is replaced by a new CAPS handler.
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
index d2d75e8..e841ad4 100644
--- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
@@ -58,6 +58,7 @@ namespace OpenSim.Region.Environment.Scenes
public event RegionUp OnRegionUp;
public event ChildAgentUpdate OnChildAgentUpdate;
public event RemoveKnownRegionsFromAvatarList OnRemoveKnownRegionFromAvatar;
+ public event LogOffUser OnLogOffUser;
private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion;
private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser;
@@ -67,6 +68,7 @@ namespace OpenSim.Region.Environment.Scenes
private RegionUp handlerRegionUp = null; // OnRegionUp;
private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar;
+ private LogOffUser handlerLogOffUser = null;
public KillObjectDelegate KillObject;
public string _debugRegionName = String.Empty;
@@ -105,6 +107,7 @@ namespace OpenSim.Region.Environment.Scenes
regionCommsHost.OnCloseAgentConnection += CloseConnection;
regionCommsHost.OnRegionUp += newRegionUp;
regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
+ regionCommsHost.OnLogOffUser += GridLogOffUser;
}
else
{
@@ -121,6 +124,7 @@ namespace OpenSim.Region.Environment.Scenes
{
if (regionCommsHost != null)
{
+ regionCommsHost.OnLogOffUser -= GridLogOffUser;
regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
regionCommsHost.OnRegionUp -= newRegionUp;
regionCommsHost.OnExpectUser -= NewUserConnection;
@@ -150,6 +154,15 @@ namespace OpenSim.Region.Environment.Scenes
}
}
+ protected void GridLogOffUser(ulong regionHandle, LLUUID AgentID, LLUUID RegionSecret, string message)
+ {
+ handlerLogOffUser = OnLogOffUser;
+ if (handlerLogOffUser != null)
+ {
+ handlerLogOffUser(regionHandle, AgentID, RegionSecret, message);
+ }
+ }
+
protected bool newRegionUp(RegionInfo region)
{
handlerRegionUp = OnRegionUp;
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 30075da..0fdd720 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -596,6 +596,7 @@ namespace OpenSim.Region.Environment.Scenes
m_scene.SendAllSceneObjectsToClient(this);
m_scene.EventManager.TriggerOnMakeRootAgent(this);
+ m_scene.CommsManager.UserService.UpdateUserCurrentRegion(UUID, m_scene.RegionInfo.RegionID, m_scene.RegionInfo.RegionHandle);
//m_gotAllObjectsInScene = true;
//}
--
cgit v1.1