From cb828c98242bf11294a9b085d8f186e37f1239e0 Mon Sep 17 00:00:00 2001
From: Teravus Ovares
Date: Tue, 26 Feb 2008 08:31:00 +0000
Subject: * More Message server stuff. Still not ready.
---
OpenSim/Grid/MessagingServer/Main.cs | 2 +-
OpenSim/Grid/MessagingServer/MessageService.cs | 103 +++++++++++++++------
OpenSim/Grid/UserServer/Main.cs | 13 ++-
OpenSim/Grid/UserServer/MessageServersConnector.cs | 97 ++++++++++++++++---
OpenSim/Grid/UserServer/UserLoginService.cs | 12 ++-
OpenSim/Grid/UserServer/UserManager.cs | 11 ++-
6 files changed, 191 insertions(+), 47 deletions(-)
diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs
index 5a383ef..bbf25f6 100644
--- a/OpenSim/Grid/MessagingServer/Main.cs
+++ b/OpenSim/Grid/MessagingServer/Main.cs
@@ -94,7 +94,7 @@ namespace OpenSim.Grid.MessagingServer
if (msgsvc.registerWithUserServer())
{
httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn);
-
+ httpServer.AddXmlRPCHandler("logout_of_simulator", msgsvc.UserLoggedOff);
//httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName);
//httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID);
//httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar);
diff --git a/OpenSim/Grid/MessagingServer/MessageService.cs b/OpenSim/Grid/MessagingServer/MessageService.cs
index 42277e2..d0b939b 100644
--- a/OpenSim/Grid/MessagingServer/MessageService.cs
+++ b/OpenSim/Grid/MessagingServer/MessageService.cs
@@ -101,22 +101,28 @@ namespace OpenSim.Grid.MessagingServer
/// The Agent we're processing the friendlist subscriptions
public void ProcessFriendListSubscriptions(UserPresenceData userpresence)
{
+ lock (m_presences)
+ {
+ if (!m_presences.Contains(userpresence.agentData.AgentID))
+ m_presences.Add(userpresence.agentData.AgentID, userpresence);
+ }
+
List uFriendList = userpresence.friendData;
for (int i = 0; i < uFriendList.Count; i++)
{
- m_presence_BackReferences.Add(userpresence.agentData.AgentID, uFriendList[i].Friend);
- m_presence_BackReferences.Add(uFriendList[i].Friend, userpresence.agentData.AgentID);
+ //m_presence_BackReferences.Add(userpresence.agentData.AgentID, uFriendList[i].Friend);
+ // m_presence_BackReferences.Add(uFriendList[i].Friend, userpresence.agentData.AgentID);
if (m_presences.Contains(uFriendList[i].Friend))
{
- UserPresenceData friendup = (UserPresenceData)m_presences[uFriendList[i]];
+ UserPresenceData friendup = (UserPresenceData)m_presences[uFriendList[i].Friend];
// Add backreference
SubscribeToPresenceUpdates(userpresence, friendup, uFriendList[i],i);
}
}
- m_presences.Add(userpresence.agentData.AgentID, userpresence);
+
}
///
@@ -220,23 +226,47 @@ namespace OpenSim.Grid.MessagingServer
///
private void ProcessLogOff(LLUUID AgentID)
{
- if (m_presences.Contains(AgentID))
+ UserPresenceData AgentData = null;
+ List AgentsNeedingNotification = new List();
+ UserPresenceData friendd = null;
+ lock (m_presences)
+ {
+ if (m_presences.Contains(AgentID))
+ {
+ AgentData = (UserPresenceData)m_presences[AgentID];
+ }
+ }
+
+ if (AgentData != null)
{
- UserPresenceData AgentData = (UserPresenceData)m_presences[AgentID];
+ AgentsNeedingNotification = AgentData.subscriptionData;
+ //lock (m_presence_BackReferences)
+ //{
+ //if (m_presence_BackReferences.Contains(AgentID))
+ //{
+ //AgentsNeedingNotification = (List)m_presence_BackReferences[AgentID];
+ //}
+ //}
- if (m_presence_BackReferences.Contains(AgentID))
+
+ for (int i = 0; i < AgentsNeedingNotification.Count; i++)
{
- List AgentsNeedingNotification = (List)m_presence_BackReferences[AgentID];
- for (int i = 0; i < AgentsNeedingNotification.Count; i++)
+ // TODO: Do Region Notifications
+ lock(m_presences)
{
- // TODO: Do Region Notifications
if (m_presences.Contains(AgentsNeedingNotification[i]))
{
- UserPresenceData friendd = (UserPresenceData)m_presences[AgentsNeedingNotification[i]];
-
- // This might need to be enumerated and checked before we try to remove it.
+ friendd = (UserPresenceData)m_presences[AgentsNeedingNotification[i]];
+ }
+ }
+
+ // This might need to be enumerated and checked before we try to remove it.
+ if (friendd != null)
+ {
+ lock (friendd)
+ {
friendd.subscriptionData.Remove(AgentID);
-
+
List fl = friendd.friendData;
for (int j = 0; j < fl.Count; j++)
{
@@ -247,15 +277,19 @@ namespace OpenSim.Grid.MessagingServer
}
friendd.friendData = fl;
-
- SendRegionPresenceUpdate(AgentData, friendd);
+ m_presences[AgentsNeedingNotification[i]] = friendd;
}
- removeBackReference(AgentID, AgentsNeedingNotification[i]);
+ SendRegionPresenceUpdate(AgentData, friendd);
+
+ //removeBackReference(AgentID, AgentsNeedingNotification[i]);
}
+
}
+
}
+
}
@@ -335,12 +369,24 @@ namespace OpenSim.Grid.MessagingServer
{
m_log.Info("[LOGON]: User logged on, building indexes for user");
Hashtable requestData = (Hashtable)request.Params[0];
+
+ //requestData["sendkey"] = serv.sendkey;
+ //requestData["agentid"] = agentID.ToString();
+ //requestData["sessionid"] = sessionID.ToString();
+ //requestData["regionid"] = RegionID.ToString();
+ //requestData["regionhandle"] = regionhandle.ToString();
+ //requestData["positionx"] = positionX.ToString();
+ //requestData["positiony"] = positionY.ToString();
+ //requestData["positionz"] = positionZ.ToString();
+ //requestData["firstname"] = firstname;
+ //requestData["lastname"] = lastname;
+
AgentCircuitData agentData = new AgentCircuitData();
- agentData.SessionID = new LLUUID((string)requestData["session_id"]);
+ agentData.SessionID = new LLUUID((string)requestData["sessionid"]);
agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
agentData.firstname = (string)requestData["firstname"];
agentData.lastname = (string)requestData["lastname"];
- agentData.AgentID = new LLUUID((string)requestData["agent_id"]);
+ agentData.AgentID = new LLUUID((string)requestData["agentid"]);
agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
agentData.CapsPath = (string)requestData["caps_path"];
@@ -351,9 +397,9 @@ namespace OpenSim.Grid.MessagingServer
else
{
agentData.startpos =
- new LLVector3(Convert.ToUInt32(requestData["startpos_x"]),
- Convert.ToUInt32(requestData["startpos_y"]),
- Convert.ToUInt32(requestData["startpos_z"]));
+ new LLVector3(Convert.ToUInt32(requestData["positionx"]),
+ Convert.ToUInt32(requestData["positiony"]),
+ Convert.ToUInt32(requestData["positionz"]));
agentData.child = false;
}
@@ -383,10 +429,10 @@ namespace OpenSim.Grid.MessagingServer
Hashtable requestData = (Hashtable)request.Params[0];
- LLUUID AgentID = new LLUUID((string)requestData["agent_id"]);
+ LLUUID AgentID = new LLUUID((string)requestData["agentid"]);
- //ProcessLogOff(AgentID);
+ ProcessLogOff(AgentID);
return new XmlRpcResponse();
@@ -458,8 +504,13 @@ namespace OpenSim.Grid.MessagingServer
regionProfile.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
regionProfile.UUID = new LLUUID((string)responseData["region_UUID"]);
regionProfile.regionName = (string)responseData["region_name"];
-
- m_regionInfoCache.Add(regionHandle, regionProfile);
+ lock (m_regionInfoCache)
+ {
+ if (!m_regionInfoCache.Contains(regionHandle))
+ {
+ m_regionInfoCache.Add(regionHandle, regionProfile);
+ }
+ }
}
catch (WebException)
{
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 3a3b8b6..fcf9de6 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -98,6 +98,7 @@ namespace OpenSim.Grid.UserServer
m_messagesService = new MessageServersConnector();
m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
+ m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
m_log.Info("[REGION]: Starting HTTP process");
BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort);
@@ -225,10 +226,18 @@ namespace OpenSim.Grid.UserServer
m_console.Notice("response got");
}
- public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position)
+ public void NotifyMessageServersUserLoggOff(LLUUID agentID)
+ {
+ m_messagesService.TellMessageServersAboutUserLogoff(agentID);
+ }
+
+ public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID,
+ ulong regionhandle, float positionX, float positionY,
+ float positionZ, string firstname, string lastname)
{
- m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, Position);
+ m_messagesService.TellMessageServersAboutUser( agentID, sessionID, RegionID, regionhandle, positionX,
+ positionY, positionZ, firstname, lastname);
}
/*private void ConfigDB(IGenericConfig configData)
diff --git a/OpenSim/Grid/UserServer/MessageServersConnector.cs b/OpenSim/Grid/UserServer/MessageServersConnector.cs
index 6535247..79d1147 100644
--- a/OpenSim/Grid/UserServer/MessageServersConnector.cs
+++ b/OpenSim/Grid/UserServer/MessageServersConnector.cs
@@ -52,12 +52,20 @@ namespace OpenSim.Grid.UserServer
public void RegisterMessageServer(string URI, MessageServerInfo serverData)
{
- MessageServers.Add(URI, serverData);
+ lock (MessageServers)
+ {
+ if (!MessageServers.ContainsKey(URI))
+ MessageServers.Add(URI, serverData);
+ }
}
public void DeRegisterMessageServer(string URI)
{
- MessageServers.Remove(URI);
+ lock (MessageServers)
+ {
+ if (MessageServers.ContainsKey(URI))
+ MessageServers.Remove(URI);
+ }
}
public void AddResponsibleRegion(string URI, ulong regionhandle)
@@ -150,24 +158,73 @@ namespace OpenSim.Grid.UserServer
return response;
}
- public void TellMessageServersAboutUser(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position)
+ public void TellMessageServersAboutUser(LLUUID agentID, LLUUID sessionID, LLUUID RegionID,
+ ulong regionhandle, float positionX, float positionY,
+ float positionZ, string firstname, string lastname)
{
// Loop over registered Message Servers ( AND THERE WILL BE MORE THEN ONE :D )
- if (MessageServers.Count > 0)
+ lock (MessageServers)
{
- m_log.Info("[MSGCONNECTOR]: Sending login notice to registered message servers");
+ if (MessageServers.Count > 0)
+ {
+ m_log.Info("[MSGCONNECTOR]: Sending login notice to registered message servers");
+ }
+ else
+ {
+ m_log.Info("[MSGCONNECTOR]: No Message Servers registered, ignoring");
+ }
+ foreach (MessageServerInfo serv in MessageServers.Values)
+ {
+ NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID,
+ regionhandle, positionX, positionY, positionZ,
+ firstname, lastname);
+ }
}
- else
+ }
+
+ public void TellMessageServersAboutUserLogoff(LLUUID agentID)
+ {
+ lock (MessageServers)
+ {
+ if (MessageServers.Count > 0)
+ {
+ m_log.Info("[MSGCONNECTOR]: Sending login notice to registered message servers");
+ }
+ else
+ {
+ m_log.Info("[MSGCONNECTOR]: No Message Servers registered, ignoring");
+ }
+ foreach (MessageServerInfo serv in MessageServers.Values)
+ {
+ NotifyMessageServerAboutUserLogoff(serv,agentID);
+ }
+ }
+ }
+
+ private void NotifyMessageServerAboutUserLogoff(MessageServerInfo serv, LLUUID agentID)
+ {
+ Hashtable reqparams = new Hashtable();
+ reqparams["sendkey"] = serv.sendkey;
+ reqparams["agentid"] = agentID.ToString();
+ ArrayList SendParams = new ArrayList();
+ SendParams.Add(reqparams);
+
+ XmlRpcRequest GridReq = new XmlRpcRequest("logout_of_simulator", SendParams);
+ try
{
- m_log.Info("[MSGCONNECTOR]: No Message Servers registered, ignoring");
+ XmlRpcResponse GridResp = GridReq.Send(serv.URI, 6000);
}
- foreach (MessageServerInfo serv in MessageServers.Values)
+ catch (System.Net.WebException)
{
- NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID, regionhandle, Position);
+ m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about log out. Other users might still think this user is online");
}
+ m_log.Info("[LOGOUT]: Notified : " + serv.URI + " about user logout");
}
- private void NotifyMessageServerAboutUser(MessageServerInfo serv, LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position)
+ private void NotifyMessageServerAboutUser(MessageServerInfo serv,
+ LLUUID agentID, LLUUID sessionID, LLUUID RegionID,
+ ulong regionhandle, float positionX, float positionY, float positionZ,
+ string firstname, string lastname)
{
Hashtable reqparams = new Hashtable();
reqparams["sendkey"] = serv.sendkey;
@@ -175,14 +232,28 @@ namespace OpenSim.Grid.UserServer
reqparams["sessionid"] = sessionID.ToString();
reqparams["regionid"] = RegionID.ToString();
reqparams["regionhandle"] = regionhandle.ToString();
- reqparams["position"] = Position.ToString();
+ reqparams["positionx"] = positionX.ToString();
+ reqparams["positiony"] = positionY.ToString();
+ reqparams["positionz"] = positionZ.ToString();
+ reqparams["firstname"] = firstname;
+ reqparams["lastname"] = lastname;
+
+ //reqparams["position"] = Position.ToString();
ArrayList SendParams = new ArrayList();
SendParams.Add(reqparams);
XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams);
- XmlRpcResponse GridResp = GridReq.Send(serv.URI, 6000);
- m_log.Info("[LOGIN]: Notified : " + serv.URI + " about user login");
+ try
+ {
+ XmlRpcResponse GridResp = GridReq.Send(serv.URI, 6000);
+ m_log.Info("[LOGIN]: Notified : " + serv.URI + " about user login");
+ }
+ catch (System.Net.WebException)
+ {
+ m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about login. Presence might be borked for this user");
+ }
+
}
}
}
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs
index a82b978..143c990 100644
--- a/OpenSim/Grid/UserServer/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer/UserLoginService.cs
@@ -44,7 +44,9 @@ using InventoryFolder=OpenSim.Framework.InventoryFolder;
namespace OpenSim.Grid.UserServer
{
- public delegate void UserLoggedInAtLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position);
+
+ public delegate void UserLoggedInAtLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID,
+ ulong regionhandle, float positionX, float positionY, float positionZ, string firstname, string lastname);
public class UserLoginService : LoginService
{
@@ -149,7 +151,9 @@ namespace OpenSim.Grid.UserServer
if (handler001 != null)
{
m_log.Info("[LOGIN]: Letting other objects know about login");
- handler001(theUser.UUID, theUser.currentAgent.sessionID, theUser.currentAgent.currentRegion, theUser.currentAgent.currentHandle, theUser.currentAgent.currentPos);
+ handler001(theUser.UUID, theUser.currentAgent.sessionID, theUser.currentAgent.currentRegion,
+ theUser.currentAgent.currentHandle, theUser.currentAgent.currentPos.X,theUser.currentAgent.currentPos.Y,theUser.currentAgent.currentPos.Z,
+ theUser.username,theUser.surname);
}
}
catch (Exception)
@@ -226,7 +230,9 @@ namespace OpenSim.Grid.UserServer
if (handler001 != null)
{
m_log.Info("[LOGIN]: Letting other objects know about login");
- handler001(theUser.UUID, theUser.currentAgent.sessionID, theUser.currentAgent.currentRegion, theUser.currentAgent.currentHandle, theUser.currentAgent.currentPos);
+ handler001(theUser.UUID, theUser.currentAgent.sessionID, theUser.currentAgent.currentRegion,
+ theUser.currentAgent.currentHandle, theUser.currentAgent.currentPos.X, theUser.currentAgent.currentPos.Y, theUser.currentAgent.currentPos.Z,
+ theUser.username, theUser.surname);
}
}
diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs
index 8f2d83c..5806f5f 100644
--- a/OpenSim/Grid/UserServer/UserManager.cs
+++ b/OpenSim/Grid/UserServer/UserManager.cs
@@ -37,10 +37,13 @@ using OpenSim.Framework.UserManagement;
namespace OpenSim.Grid.UserServer
{
+ public delegate void logOffUser(LLUUID AgentID);
+
public class UserManager : UserManagerBase
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
-
+ public event logOffUser OnLogOffUser;
+ private logOffUser handler001 = null;
///
/// Deletes an active agent session
///
@@ -327,7 +330,11 @@ namespace OpenSim.Grid.UserServer
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"]);
-
+
+ handler001 = OnLogOffUser;
+ if (handler001 != null)
+ handler001(userUUID);
+
LogOffUser(userUUID, RegionID, regionhandle, posx, posy, posz);
}
catch (FormatException)
--
cgit v1.1