* More Message server stuff. Still not ready.

0.6.0-stable
Teravus Ovares 2008-02-26 08:31:00 +00:00
parent 65862aacea
commit cb828c9824
6 changed files with 196 additions and 52 deletions

View File

@ -94,7 +94,7 @@ namespace OpenSim.Grid.MessagingServer
if (msgsvc.registerWithUserServer()) if (msgsvc.registerWithUserServer())
{ {
httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn); 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_name", m_userManager.XmlRPCGetUserMethodName);
//httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID); //httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID);
//httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar); //httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar);

View File

@ -101,22 +101,28 @@ namespace OpenSim.Grid.MessagingServer
/// <param name="userpresence">The Agent we're processing the friendlist subscriptions</param> /// <param name="userpresence">The Agent we're processing the friendlist subscriptions</param>
public void ProcessFriendListSubscriptions(UserPresenceData userpresence) public void ProcessFriendListSubscriptions(UserPresenceData userpresence)
{ {
lock (m_presences)
{
if (!m_presences.Contains(userpresence.agentData.AgentID))
m_presences.Add(userpresence.agentData.AgentID, userpresence);
}
List<FriendListItem> uFriendList = userpresence.friendData; List<FriendListItem> uFriendList = userpresence.friendData;
for (int i = 0; i < uFriendList.Count; i++) for (int i = 0; i < uFriendList.Count; i++)
{ {
m_presence_BackReferences.Add(userpresence.agentData.AgentID, uFriendList[i].Friend); //m_presence_BackReferences.Add(userpresence.agentData.AgentID, uFriendList[i].Friend);
m_presence_BackReferences.Add(uFriendList[i].Friend, userpresence.agentData.AgentID); // m_presence_BackReferences.Add(uFriendList[i].Friend, userpresence.agentData.AgentID);
if (m_presences.Contains(uFriendList[i].Friend)) if (m_presences.Contains(uFriendList[i].Friend))
{ {
UserPresenceData friendup = (UserPresenceData)m_presences[uFriendList[i]]; UserPresenceData friendup = (UserPresenceData)m_presences[uFriendList[i].Friend];
// Add backreference // Add backreference
SubscribeToPresenceUpdates(userpresence, friendup, uFriendList[i],i); SubscribeToPresenceUpdates(userpresence, friendup, uFriendList[i],i);
} }
} }
m_presences.Add(userpresence.agentData.AgentID, userpresence);
} }
/// <summary> /// <summary>
@ -219,22 +225,46 @@ namespace OpenSim.Grid.MessagingServer
/// </summary> /// </summary>
/// <param name="AgentID"></param> /// <param name="AgentID"></param>
private void ProcessLogOff(LLUUID AgentID) private void ProcessLogOff(LLUUID AgentID)
{
UserPresenceData AgentData = null;
List<LLUUID> AgentsNeedingNotification = new List<LLUUID>();
UserPresenceData friendd = null;
lock (m_presences)
{ {
if (m_presences.Contains(AgentID)) if (m_presences.Contains(AgentID))
{ {
UserPresenceData AgentData = (UserPresenceData)m_presences[AgentID]; AgentData = (UserPresenceData)m_presences[AgentID];
}
}
if (m_presence_BackReferences.Contains(AgentID)) if (AgentData != null)
{ {
List<LLUUID> AgentsNeedingNotification = (List<LLUUID>)m_presence_BackReferences[AgentID]; AgentsNeedingNotification = AgentData.subscriptionData;
//lock (m_presence_BackReferences)
//{
//if (m_presence_BackReferences.Contains(AgentID))
//{
//AgentsNeedingNotification = (List<LLUUID>)m_presence_BackReferences[AgentID];
//}
//}
for (int i = 0; i < AgentsNeedingNotification.Count; i++) for (int i = 0; i < AgentsNeedingNotification.Count; i++)
{ {
// TODO: Do Region Notifications // TODO: Do Region Notifications
lock(m_presences)
{
if (m_presences.Contains(AgentsNeedingNotification[i])) if (m_presences.Contains(AgentsNeedingNotification[i]))
{ {
UserPresenceData friendd = (UserPresenceData)m_presences[AgentsNeedingNotification[i]]; friendd = (UserPresenceData)m_presences[AgentsNeedingNotification[i]];
}
}
// This might need to be enumerated and checked before we try to remove it. // This might need to be enumerated and checked before we try to remove it.
if (friendd != null)
{
lock (friendd)
{
friendd.subscriptionData.Remove(AgentID); friendd.subscriptionData.Remove(AgentID);
List<FriendListItem> fl = friendd.friendData; List<FriendListItem> fl = friendd.friendData;
@ -247,15 +277,19 @@ namespace OpenSim.Grid.MessagingServer
} }
friendd.friendData = fl; friendd.friendData = fl;
m_presences[AgentsNeedingNotification[i]] = friendd;
}
SendRegionPresenceUpdate(AgentData, friendd); SendRegionPresenceUpdate(AgentData, friendd);
//removeBackReference(AgentID, AgentsNeedingNotification[i]);
} }
removeBackReference(AgentID, AgentsNeedingNotification[i]);
} }
} }
}
} }
@ -335,12 +369,24 @@ namespace OpenSim.Grid.MessagingServer
{ {
m_log.Info("[LOGON]: User logged on, building indexes for user"); m_log.Info("[LOGON]: User logged on, building indexes for user");
Hashtable requestData = (Hashtable)request.Params[0]; 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(); 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.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
agentData.firstname = (string)requestData["firstname"]; agentData.firstname = (string)requestData["firstname"];
agentData.lastname = (string)requestData["lastname"]; 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.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
agentData.CapsPath = (string)requestData["caps_path"]; agentData.CapsPath = (string)requestData["caps_path"];
@ -351,9 +397,9 @@ namespace OpenSim.Grid.MessagingServer
else else
{ {
agentData.startpos = agentData.startpos =
new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), new LLVector3(Convert.ToUInt32(requestData["positionx"]),
Convert.ToUInt32(requestData["startpos_y"]), Convert.ToUInt32(requestData["positiony"]),
Convert.ToUInt32(requestData["startpos_z"])); Convert.ToUInt32(requestData["positionz"]));
agentData.child = false; agentData.child = false;
} }
@ -383,10 +429,10 @@ namespace OpenSim.Grid.MessagingServer
Hashtable requestData = (Hashtable)request.Params[0]; 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(); return new XmlRpcResponse();
@ -458,9 +504,14 @@ namespace OpenSim.Grid.MessagingServer
regionProfile.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); regionProfile.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
regionProfile.UUID = new LLUUID((string)responseData["region_UUID"]); regionProfile.UUID = new LLUUID((string)responseData["region_UUID"]);
regionProfile.regionName = (string)responseData["region_name"]; regionProfile.regionName = (string)responseData["region_name"];
lock (m_regionInfoCache)
{
if (!m_regionInfoCache.Contains(regionHandle))
{
m_regionInfoCache.Add(regionHandle, regionProfile); m_regionInfoCache.Add(regionHandle, regionProfile);
} }
}
}
catch (WebException) catch (WebException)
{ {
m_log.Error("[GRID]: " + m_log.Error("[GRID]: " +

View File

@ -98,6 +98,7 @@ namespace OpenSim.Grid.UserServer
m_messagesService = new MessageServersConnector(); m_messagesService = new MessageServersConnector();
m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation; m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
m_log.Info("[REGION]: Starting HTTP process"); m_log.Info("[REGION]: Starting HTTP process");
BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort);
@ -225,10 +226,18 @@ namespace OpenSim.Grid.UserServer
m_console.Notice("response got"); 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) /*private void ConfigDB(IGenericConfig configData)

View File

@ -52,13 +52,21 @@ namespace OpenSim.Grid.UserServer
public void RegisterMessageServer(string URI, MessageServerInfo serverData) public void RegisterMessageServer(string URI, MessageServerInfo serverData)
{ {
lock (MessageServers)
{
if (!MessageServers.ContainsKey(URI))
MessageServers.Add(URI, serverData); MessageServers.Add(URI, serverData);
} }
}
public void DeRegisterMessageServer(string URI) public void DeRegisterMessageServer(string URI)
{ {
lock (MessageServers)
{
if (MessageServers.ContainsKey(URI))
MessageServers.Remove(URI); MessageServers.Remove(URI);
} }
}
public void AddResponsibleRegion(string URI, ulong regionhandle) public void AddResponsibleRegion(string URI, ulong regionhandle)
{ {
@ -150,9 +158,13 @@ namespace OpenSim.Grid.UserServer
return response; 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 ) // Loop over registered Message Servers ( AND THERE WILL BE MORE THEN ONE :D )
lock (MessageServers)
{
if (MessageServers.Count > 0) if (MessageServers.Count > 0)
{ {
m_log.Info("[MSGCONNECTOR]: Sending login notice to registered message servers"); m_log.Info("[MSGCONNECTOR]: Sending login notice to registered message servers");
@ -163,11 +175,56 @@ namespace OpenSim.Grid.UserServer
} }
foreach (MessageServerInfo serv in MessageServers.Values) foreach (MessageServerInfo serv in MessageServers.Values)
{ {
NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID, regionhandle, Position); NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID,
regionhandle, positionX, positionY, positionZ,
firstname, lastname);
}
} }
} }
private void NotifyMessageServerAboutUser(MessageServerInfo serv, LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position) 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
{
XmlRpcResponse GridResp = GridReq.Send(serv.URI, 6000);
}
catch (System.Net.WebException)
{
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, float positionX, float positionY, float positionZ,
string firstname, string lastname)
{ {
Hashtable reqparams = new Hashtable(); Hashtable reqparams = new Hashtable();
reqparams["sendkey"] = serv.sendkey; reqparams["sendkey"] = serv.sendkey;
@ -175,14 +232,28 @@ namespace OpenSim.Grid.UserServer
reqparams["sessionid"] = sessionID.ToString(); reqparams["sessionid"] = sessionID.ToString();
reqparams["regionid"] = RegionID.ToString(); reqparams["regionid"] = RegionID.ToString();
reqparams["regionhandle"] = regionhandle.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(); ArrayList SendParams = new ArrayList();
SendParams.Add(reqparams); SendParams.Add(reqparams);
XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams); XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams);
try
{
XmlRpcResponse GridResp = GridReq.Send(serv.URI, 6000); XmlRpcResponse GridResp = GridReq.Send(serv.URI, 6000);
m_log.Info("[LOGIN]: Notified : " + serv.URI + " about user login"); 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");
}
}
} }
} }

View File

@ -44,7 +44,9 @@ using InventoryFolder=OpenSim.Framework.InventoryFolder;
namespace OpenSim.Grid.UserServer 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 public class UserLoginService : LoginService
{ {
@ -149,7 +151,9 @@ namespace OpenSim.Grid.UserServer
if (handler001 != null) if (handler001 != null)
{ {
m_log.Info("[LOGIN]: Letting other objects know about login"); 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) catch (Exception)
@ -226,7 +230,9 @@ namespace OpenSim.Grid.UserServer
if (handler001 != null) if (handler001 != null)
{ {
m_log.Info("[LOGIN]: Letting other objects know about login"); 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);
} }
} }

View File

@ -37,10 +37,13 @@ using OpenSim.Framework.UserManagement;
namespace OpenSim.Grid.UserServer namespace OpenSim.Grid.UserServer
{ {
public delegate void logOffUser(LLUUID AgentID);
public class UserManager : UserManagerBase public class UserManager : UserManagerBase
{ {
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public event logOffUser OnLogOffUser;
private logOffUser handler001 = null;
/// <summary> /// <summary>
/// Deletes an active agent session /// Deletes an active agent session
/// </summary> /// </summary>
@ -328,6 +331,10 @@ namespace OpenSim.Grid.UserServer
float posy = (float)Convert.ToDecimal((string)requestData["region_pos_y"]); float posy = (float)Convert.ToDecimal((string)requestData["region_pos_y"]);
float posz = (float)Convert.ToDecimal((string)requestData["region_pos_z"]); float posz = (float)Convert.ToDecimal((string)requestData["region_pos_z"]);
handler001 = OnLogOffUser;
if (handler001 != null)
handler001(userUUID);
LogOffUser(userUUID, RegionID, regionhandle, posx, posy, posz); LogOffUser(userUUID, RegionID, regionhandle, posx, posy, posz);
} }
catch (FormatException) catch (FormatException)