* 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())
{
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);

View File

@ -101,22 +101,28 @@ namespace OpenSim.Grid.MessagingServer
/// <param name="userpresence">The Agent we're processing the friendlist subscriptions</param>
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;
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);
}
/// <summary>
@ -220,23 +226,47 @@ namespace OpenSim.Grid.MessagingServer
/// <param name="AgentID"></param>
private void ProcessLogOff(LLUUID AgentID)
{
if (m_presences.Contains(AgentID))
UserPresenceData AgentData = null;
List<LLUUID> AgentsNeedingNotification = new List<LLUUID>();
UserPresenceData friendd = null;
lock (m_presences)
{
UserPresenceData AgentData = (UserPresenceData)m_presences[AgentID];
if (m_presence_BackReferences.Contains(AgentID))
if (m_presences.Contains(AgentID))
{
List<LLUUID> AgentsNeedingNotification = (List<LLUUID>)m_presence_BackReferences[AgentID];
for (int i = 0; i < AgentsNeedingNotification.Count; i++)
AgentData = (UserPresenceData)m_presences[AgentID];
}
}
if (AgentData != null)
{
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++)
{
// 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<FriendListItem> 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)
{

View File

@ -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)

View File

@ -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");
}
else
{
m_log.Info("[MSGCONNECTOR]: No Message Servers registered, ignoring");
}
foreach (MessageServerInfo serv in MessageServers.Values)
{
NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID, regionhandle, Position);
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);
}
}
}
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();
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");
}
}
}
}

View File

@ -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);
}
}

View File

@ -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;
/// <summary>
/// Deletes an active agent session
/// </summary>
@ -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)