* Rex merges, user server.

afrisby-3
Adam Frisby 2008-02-23 02:57:50 +00:00
parent 7caa40e301
commit b526c42d06
5 changed files with 1268 additions and 1188 deletions

View File

@ -36,21 +36,22 @@ using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Framework.Statistics;
namespace OpenSim.Grid.UserServer namespace OpenSim.Grid.UserServer
{ {
/// <summary> /// <summary>
/// </summary> /// </summary>
public class OpenUser_Main : conscmd_callback public class OpenUser_Main : BaseOpenSimServer, conscmd_callback
{ {
private UserConfig Cfg; private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private UserConfig Cfg;
public UserManager m_userManager; public UserManager m_userManager;
public UserLoginService m_loginService; public UserLoginService m_loginService;
public MessageServersConnector m_messagesService; public MessageServersConnector m_messagesService;
private LogBase m_console;
private LLUUID m_lastCreatedUser = LLUUID.Random(); private LLUUID m_lastCreatedUser = LLUUID.Random();
private Boolean m_rexMode; private Boolean m_rexMode;
@ -58,7 +59,9 @@ namespace OpenSim.Grid.UserServer
[STAThread] [STAThread]
public static void Main(string[] args) public static void Main(string[] args)
{ {
Console.WriteLine("Launching UserServer..."); log4net.Config.XmlConfigurator.Configure();
m_log.Info("Launching UserServer...");
OpenUser_Main userserver = new OpenUser_Main(); OpenUser_Main userserver = new OpenUser_Main();
@ -68,13 +71,8 @@ namespace OpenSim.Grid.UserServer
private OpenUser_Main() private OpenUser_Main()
{ {
if (!Directory.Exists(Util.logDir())) m_console = new ConsoleBase("OpenUser", this);
{ MainConsole.Instance = m_console;
Directory.CreateDirectory(Util.logDir());
}
m_console =
new LogBase((Path.Combine(Util.logDir(), "opengrid-userserver-console.log")), "OpenUser", this, true);
MainLog.Instance = m_console;
} }
private void Work() private void Work()
@ -83,7 +81,7 @@ namespace OpenSim.Grid.UserServer
while (true) while (true)
{ {
m_console.MainLogPrompt(); m_console.Prompt();
} }
} }
@ -91,7 +89,9 @@ namespace OpenSim.Grid.UserServer
{ {
Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
MainLog.Instance.Verbose("REGION", "Establishing data connection"); StatsManager.StartCollectingUserStats();
m_log.Info("[REGION]: Establishing data connection");
m_userManager = new UserManager(); m_userManager = new UserManager();
m_userManager._config = Cfg; m_userManager._config = Cfg;
m_userManager.AddPlugin(Cfg.DatabaseProvider); m_userManager.AddPlugin(Cfg.DatabaseProvider);
@ -100,18 +100,19 @@ namespace OpenSim.Grid.UserServer
m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg);
m_rexMode = Cfg.RexMode; m_rexMode = Cfg.RexMode;
m_messagesService = new MessageServersConnector(MainLog.Instance); m_messagesService = new MessageServersConnector();
m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation; m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
MainLog.Instance.Verbose("REGION", "Starting HTTP process"); m_log.Info("[REGION]: Starting HTTP process");
BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort);
httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod);
httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin);
httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod); httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod);
if (!m_rexMode) {
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);
@ -119,6 +120,12 @@ namespace OpenSim.Grid.UserServer
httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend); httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend);
httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms); httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms);
httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList); 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);
httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion);
httpServer.AddXmlRPCHandler("deregister_messageserver", m_messagesService.XmlRPCDeRegisterMessageServer);
// Message Server ---> User Server // Message Server ---> User Server
httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer); httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer);
@ -144,10 +151,9 @@ namespace OpenSim.Grid.UserServer
new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
httpServer.Start(); httpServer.Start();
m_console.Status("SERVER", "Userserver 0.4 - Startup complete"); m_log.Info("[SERVER]: Userserver 0.5 - Startup complete");
} }
public void do_create(string what) public void do_create(string what)
{ {
switch (what) switch (what)
@ -161,11 +167,18 @@ namespace OpenSim.Grid.UserServer
tempfirstname = m_console.CmdPrompt("First name"); tempfirstname = m_console.CmdPrompt("First name");
templastname = m_console.CmdPrompt("Last name"); templastname = m_console.CmdPrompt("Last name");
tempMD5Passwd = m_console.PasswdPrompt("Password"); //tempMD5Passwd = m_console.PasswdPrompt("Password");
tempMD5Passwd = m_console.CmdPrompt("Password");
regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X")); regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X"));
regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y")); regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y"));
tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); if (null != m_userManager.GetUserProfile(tempfirstname, templastname))
{
m_log.ErrorFormat("[USERS]: A user with the name {0} {1} already exists!", tempfirstname, templastname);
break;
}
tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty);
LLUUID userID = new LLUUID(); LLUUID userID = new LLUUID();
try try
@ -174,7 +187,7 @@ namespace OpenSim.Grid.UserServer
m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
} catch (Exception ex) } catch (Exception ex)
{ {
m_console.Error("SERVER", "Error creating user: {0}", ex.ToString()); m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString());
} }
try try
@ -184,19 +197,22 @@ namespace OpenSim.Grid.UserServer
} }
catch (Exception ex) catch (Exception ex)
{ {
m_console.Error("SERVER", "Error creating inventory for user: {0}", ex.ToString()); m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", ex.ToString());
} }
m_lastCreatedUser = userID; m_lastCreatedUser = userID;
break; break;
} }
} }
public void RunCmd(string cmd, string[] cmdparams) public override void RunCmd(string cmd, string[] cmdparams)
{ {
base.RunCmd(cmd, cmdparams);
switch (cmd) switch (cmd)
{ {
case "help": case "help":
m_console.Notice("create user - create a new user"); m_console.Notice("create user - create a new user");
m_console.Notice("stats - statistical information for this server");
m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
break; break;
@ -210,11 +226,14 @@ namespace OpenSim.Grid.UserServer
Environment.Exit(0); Environment.Exit(0);
break; break;
case "stats":
m_console.Notice(StatsManager.UserStats.Report());
break;
case "test-inventory": case "test-inventory":
// RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>(); // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
// requester.ReturnResponseVal = TestResponse; // requester.ReturnResponseVal = TestResponse;
// requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); // requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
List<InventoryFolderBase> folders =
SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST", SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST",
m_userManager. m_userManager.
_config. _config.
@ -227,8 +246,9 @@ namespace OpenSim.Grid.UserServer
public void TestResponse(List<InventoryFolderBase> resp) public void TestResponse(List<InventoryFolderBase> resp)
{ {
Console.WriteLine("response got"); m_console.Notice("response got");
} }
public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position) public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position)
{ {
m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, Position); m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, Position);
@ -238,9 +258,9 @@ namespace OpenSim.Grid.UserServer
{ {
try try
{ {
string attri = ""; string attri = String.Empty;
attri = configData.GetAttribute("DataBaseProvider"); attri = configData.GetAttribute("DataBaseProvider");
if (attri == "") if (attri == String.Empty)
{ {
StorageDll = "OpenSim.Framework.Data.DB4o.dll"; StorageDll = "OpenSim.Framework.Data.DB4o.dll";
configData.SetAttribute("DataBaseProvider", "OpenSim.Framework.Data.DB4o.dll"); configData.SetAttribute("DataBaseProvider", "OpenSim.Framework.Data.DB4o.dll");
@ -256,10 +276,6 @@ namespace OpenSim.Grid.UserServer
} }
}*/ }*/
public void Show(string ShowWhat)
{
}
} }
/// <summary> /// <summary>

View File

@ -39,15 +39,14 @@ using OpenSim.Framework.Servers;
namespace OpenSim.Grid.UserServer namespace OpenSim.Grid.UserServer
{ {
public class MessageServersConnector public class MessageServersConnector
{ {
private LogBase m_log; private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public Dictionary<string, MessageServerInfo> MessageServers; public Dictionary<string, MessageServerInfo> MessageServers;
public MessageServersConnector(LogBase log) public MessageServersConnector()
{ {
m_log=log;
MessageServers = new Dictionary<string, MessageServerInfo>(); MessageServers = new Dictionary<string, MessageServerInfo>();
} }
@ -65,7 +64,7 @@ namespace OpenSim.Grid.UserServer
{ {
if (!MessageServers.ContainsKey(URI)) if (!MessageServers.ContainsKey(URI))
{ {
m_log.Warn("MSGSERVER", "Got addResponsibleRegion Request for a MessageServer that isn't registered"); m_log.Warn("[MSGSERVER]: Got addResponsibleRegion Request for a MessageServer that isn't registered");
} }
else else
{ {
@ -78,7 +77,7 @@ namespace OpenSim.Grid.UserServer
{ {
if (!MessageServers.ContainsKey(URI)) if (!MessageServers.ContainsKey(URI))
{ {
m_log.Warn("MSGSERVER", "Got RemoveResponsibleRegion Request for a MessageServer that isn't registered"); m_log.Warn("[MSGSERVER]: Got RemoveResponsibleRegion Request for a MessageServer that isn't registered");
} }
else else
{ {
@ -175,10 +174,7 @@ namespace OpenSim.Grid.UserServer
XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams); XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams);
XmlRpcResponse GridResp = GridReq.Send(serv.URI, 6000); XmlRpcResponse GridResp = GridReq.Send(serv.URI, 6000);
m_log.Verbose("LOGIN","Notified : " + serv.URI + " about user login"); m_log.Info("[LOGIN]: Notified : " + serv.URI + " about user login");
} }
} }
} }

View File

@ -1,3 +1,31 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@ -10,7 +38,7 @@ using System.Runtime.InteropServices;
[assembly : AssemblyConfiguration("")] [assembly : AssemblyConfiguration("")]
[assembly : AssemblyCompany("")] [assembly : AssemblyCompany("")]
[assembly : AssemblyProduct("OGS-UserServer")] [assembly : AssemblyProduct("OGS-UserServer")]
[assembly : AssemblyCopyright("Copyright © 2007")] [assembly : AssemblyCopyright("Copyright © OpenSimulator.org Developers 2007-2008")]
[assembly : AssemblyTrademark("")] [assembly : AssemblyTrademark("")]
[assembly : AssemblyCulture("")] [assembly : AssemblyCulture("")]

View File

@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
@ -38,6 +38,7 @@ using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Data; using OpenSim.Framework.Data;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using OpenSim.Framework.Statistics;
using OpenSim.Framework.UserManagement; using OpenSim.Framework.UserManagement;
using InventoryFolder=OpenSim.Framework.InventoryFolder; using InventoryFolder=OpenSim.Framework.InventoryFolder;
@ -45,15 +46,19 @@ 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, LLVector3 Position);
public class UserLoginService : LoginService public class UserLoginService : LoginService
{ {
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public event UserLoggedInAtLocation OnUserLoggedInAtLocation; public event UserLoggedInAtLocation OnUserLoggedInAtLocation;
private UserLoggedInAtLocation handler001 = null;
public UserConfig m_config; public UserConfig m_config;
public UserLoginService( public UserLoginService(
UserManagerBase userManager, LibraryRootFolder libraryRootFolder, UserConfig config, string welcomeMess) UserManagerBase userManager, LibraryRootFolder libraryRootFolder,
UserConfig config, string welcomeMess)
: base(userManager, libraryRootFolder, welcomeMess, config.RexMode) : base(userManager, libraryRootFolder, welcomeMess, config.RexMode)
{ {
m_config = config; m_config = config;
@ -68,19 +73,20 @@ namespace OpenSim.Grid.UserServer
{ {
bool tryDefault = false; bool tryDefault = false;
//CFK: Since the try is always "tried", the "Home Location" message should always appear, so comment this one. //CFK: Since the try is always "tried", the "Home Location" message should always appear, so comment this one.
//CFK: MainLog.Instance.Verbose("LOGIN", "Load information from the gridserver"); //CFK: m_log.Info("[LOGIN]: Load information from the gridserver");
RegionProfileData SimInfo = new RegionProfileData();
try try
{ {
SimInfo = RegionProfileData SimInfo =
SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, m_config.GridServerURL, RegionProfileData.RequestSimProfileData(
theUser.currentAgent.currentHandle, m_config.GridServerURL,
m_config.GridSendKey, m_config.GridRecvKey); m_config.GridSendKey, m_config.GridRecvKey);
// Customise the response // Customise the response
//CFK: This is redundant and the next message should always appear. //CFK: This is redundant and the next message should always appear.
//CFK: MainLog.Instance.Verbose("LOGIN", "Home Location"); //CFK: m_log.Info("[LOGIN]: Home Location");
response.Home = "{'region_handle':[r" + (SimInfo.regionLocX*256).ToString() + ",r" + response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" +
(SimInfo.regionLocY*256).ToString() + "], " + (SimInfo.regionLocY * Constants.RegionSize).ToString() + "], " +
"'position':[r" + theUser.homeLocation.X.ToString() + ",r" + "'position':[r" + theUser.homeLocation.X.ToString() + ",r" +
theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
"'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" +
@ -89,7 +95,7 @@ namespace OpenSim.Grid.UserServer
// Destination // Destination
//CFK: The "Notifying" message always seems to appear, so subsume the data from this message into //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into
//CFK: the next one for X & Y and comment this one. //CFK: the next one for X & Y and comment this one.
//CFK: MainLog.Instance.Verbose("LOGIN", "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + //CFK: m_log.Info("[LOGIN]: CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX +
//CFK: "; Region Y: " + SimInfo.regionLocY); //CFK: "; Region Y: " + SimInfo.regionLocY);
response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString(); response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
response.SimPort = (uint) SimInfo.serverPort; response.SimPort = (uint) SimInfo.serverPort;
@ -103,7 +109,7 @@ namespace OpenSim.Grid.UserServer
// Notify the target of an incoming user // Notify the target of an incoming user
//CFK: The "Notifying" message always seems to appear, so subsume the data from this message into //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into
//CFK: the next one for X & Y and comment this one. //CFK: the next one for X & Y and comment this one.
//CFK: MainLog.Instance.Verbose("LOGIN", SimInfo.regionName + " (" + SimInfo.serverURI + ") " + //CFK: m_log.Info("[LOGIN]: " + SimInfo.regionName + " (" + SimInfo.serverURI + ") " +
//CFK: SimInfo.regionLocX + "," + SimInfo.regionLocY); //CFK: SimInfo.regionLocX + "," + SimInfo.regionLocY);
// Prepare notification // Prepare notification
@ -132,45 +138,52 @@ namespace OpenSim.Grid.UserServer
theUser.currentAgent.currentRegion = SimInfo.UUID; theUser.currentAgent.currentRegion = SimInfo.UUID;
theUser.currentAgent.currentHandle = SimInfo.regionHandle; theUser.currentAgent.currentHandle = SimInfo.regionHandle;
MainLog.Instance.Verbose("LOGIN", SimInfo.regionName + " @ " + SimInfo.httpServerURI + " " + m_log.Info("[LOGIN]: Telling "
SimInfo.regionLocX + "," + SimInfo.regionLocY); + SimInfo.regionName + " @ " + SimInfo.httpServerURI + " " +
SimInfo.regionLocX + "," + SimInfo.regionLocY + " to expect user connection");
XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
if (GridResp.IsFault)
{
m_log.ErrorFormat(
"[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}",
SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
}
} }
catch (Exception) catch (Exception)
{ {
tryDefault = true; tryDefault = true;
} }
if (tryDefault) if (tryDefault)
{ {
// Send him to default region instead // Send him to default region instead
// Load information from the gridserver // Load information from the gridserver
ulong defaultHandle = (((ulong) m_config.DefaultX*256) << 32) | ((ulong) m_config.DefaultY*256); ulong defaultHandle = (((ulong)m_config.DefaultX * Constants.RegionSize) << 32) | ((ulong)m_config.DefaultY * Constants.RegionSize);
MainLog.Instance.Warn( m_log.Warn(
"LOGIN", "[LOGIN]: Home region not available: sending to default " + defaultHandle.ToString());
"Home region not available: sending to default " + defaultHandle.ToString());
SimInfo = new RegionProfileData();
try try
{ {
SimInfo = RegionProfileData SimInfo = RegionProfileData.RequestSimProfileData(
SimInfo.RequestSimProfileData(defaultHandle, m_config.GridServerURL, defaultHandle, m_config.GridServerURL,
m_config.GridSendKey, m_config.GridRecvKey); m_config.GridSendKey, m_config.GridRecvKey);
// Customise the response // Customise the response
MainLog.Instance.Verbose("LOGIN", "Home Location"); m_log.Info("[LOGIN]: Home Location");
response.Home = "{'region_handle':[r" + (SimInfo.regionLocX*256).ToString() + ",r" + response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" +
(SimInfo.regionLocY*256).ToString() + "], " + (SimInfo.regionLocY * Constants.RegionSize).ToString() + "], " +
"'position':[r" + theUser.homeLocation.X.ToString() + ",r" + "'position':[r" + theUser.homeLocation.X.ToString() + ",r" +
theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
"'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" +
theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
// Destination // Destination
MainLog.Instance.Verbose("LOGIN", m_log.Info("[LOGIN]: " +
"CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " +
SimInfo.regionLocY); SimInfo.regionLocY);
response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString(); response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
@ -183,7 +196,7 @@ namespace OpenSim.Grid.UserServer
response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
// Notify the target of an incoming user // Notify the target of an incoming user
MainLog.Instance.Verbose("LOGIN", "Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")"); m_log.Info("[LOGIN]: Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")");
// Update agent with target sim // Update agent with target sim
theUser.currentAgent.currentRegion = SimInfo.UUID; theUser.currentAgent.currentRegion = SimInfo.UUID;
@ -211,20 +224,21 @@ namespace OpenSim.Grid.UserServer
ArrayList SendParams = new ArrayList(); ArrayList SendParams = new ArrayList();
SendParams.Add(SimParams); SendParams.Add(SimParams);
MainLog.Instance.Verbose("LOGIN", "Informing region at " + SimInfo.httpServerURI); m_log.Info("[LOGIN]: Informing region at " + SimInfo.httpServerURI);
// Send // Send
XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
if (OnUserLoggedInAtLocation != null) handler001 = OnUserLoggedInAtLocation;
if (handler001 != null)
{ {
OnUserLoggedInAtLocation(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);
} }
} }
catch (Exception e) catch (Exception e)
{ {
MainLog.Instance.Warn("LOGIN", "Default region also not available"); m_log.Warn("[LOGIN]: Default region also not available");
MainLog.Instance.Warn("LOGIN", e.ToString()); m_log.Warn("[LOGIN]: " + e.ToString());
} }
} }
} }
@ -240,10 +254,9 @@ namespace OpenSim.Grid.UserServer
// which does. // which does.
if (null == folders | folders.Count == 0) if (null == folders | folders.Count == 0)
{ {
MainLog.Instance.Warn( m_log.Warn(
"LOGIN", "[LOGIN]: " +
"A root inventory folder for user ID " + userID + " was not found. A new set" "root inventory folder user " + userID + " not found. Creating.");
+ " of empty inventory folders is being created.");
RestObjectPoster.BeginPostObject<Guid>( RestObjectPoster.BeginPostObject<Guid>(
m_config.InventoryUrl + "CreateInventory/", userID.UUID); m_config.InventoryUrl + "CreateInventory/", userID.UUID);
@ -279,7 +292,7 @@ namespace OpenSim.Grid.UserServer
} }
else else
{ {
MainLog.Instance.Warn("LOGIN", "The root inventory folder could still not be retrieved" + m_log.Warn("[LOGIN]: The root inventory folder could still not be retrieved" +
" for user ID " + userID); " for user ID " + userID);
AgentInventory userInventory = new AgentInventory(); AgentInventory userInventory = new AgentInventory();

View File

@ -32,16 +32,14 @@ using System.Text.RegularExpressions;
using libsecondlife; using libsecondlife;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Statistics;
using OpenSim.Framework.UserManagement; using OpenSim.Framework.UserManagement;
namespace OpenSim.Grid.UserServer namespace OpenSim.Grid.UserServer
{ {
public class UserManager : UserManagerBase public class UserManager : UserManagerBase
{ {
public UserManager() private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
{
}
/// <summary> /// <summary>
/// Deletes an active agent session /// Deletes an active agent session
@ -110,6 +108,7 @@ namespace OpenSim.Grid.UserServer
return response; return response;
} }
/// <summary> /// <summary>
/// Converts a user profile to an XML element which can be returned /// Converts a user profile to an XML element which can be returned
/// </summary> /// </summary>
@ -206,7 +205,6 @@ namespace OpenSim.Grid.UserServer
responseData["returnString"] = returnString; responseData["returnString"] = returnString;
response.Value = responseData; response.Value = responseData;
return response; return response;
} }
public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request) public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request)
@ -216,8 +214,6 @@ namespace OpenSim.Grid.UserServer
Hashtable responseData = new Hashtable(); Hashtable responseData = new Hashtable();
string returnString = "FALSE"; string returnString = "FALSE";
if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms")) if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms"))
{ {
UpdateUserFriendPerms(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]), (uint)Convert.ToInt32((string)requestData["friendPerms"])); UpdateUserFriendPerms(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]), (uint)Convert.ToInt32((string)requestData["friendPerms"]));
@ -237,8 +233,6 @@ namespace OpenSim.Grid.UserServer
List<FriendListItem> returndata = new List<FriendListItem>(); List<FriendListItem> returndata = new List<FriendListItem>();
if (requestData.Contains("ownerID")) if (requestData.Contains("ownerID"))
{ {
returndata = this.GetUserFriendList(new LLUUID((string)requestData["ownerID"])); returndata = this.GetUserFriendList(new LLUUID((string)requestData["ownerID"]));
@ -324,10 +318,43 @@ namespace OpenSim.Grid.UserServer
return CreateUnknownUserErrorResponse(); return CreateUnknownUserErrorResponse();
} }
return ProfileToXmlRPCResponse(userProfile); 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)
{
m_log.Warn("[LOGOUT]: Error in Logout XMLRPC Params");
return response;
}
}
else
{
return CreateUnknownUserErrorResponse();
}
return response;
}
#endregion #endregion
public override UserProfileData SetupMasterUser(string firstName, string lastName) public override UserProfileData SetupMasterUser(string firstName, string lastName)