* Refactored out common http handler operations

0.6.0-stable
lbsa71 2008-03-28 21:43:46 +00:00
parent ca718b6f8d
commit 7f11079f57
6 changed files with 94 additions and 104 deletions

View File

@ -37,6 +37,12 @@ namespace OpenSim.Framework.Servers
{
protected ConsoleBase m_console;
protected DateTime m_startuptime;
protected BaseHttpServer m_httpServer;
public BaseHttpServer HttpServer
{
get { return m_httpServer; }
}
public BaseOpenSimServer()
{

View File

@ -51,7 +51,7 @@ namespace OpenSim.Grid.AssetServer
// Temporarily hardcoded - should be a plugin
protected IAssetLoader assetLoader = new AssetLoaderFileSystem();
private IAssetProvider m_assetProvider;
private IAssetProvider m_assetProvider;
[STAThread]
public static void Main(string[] args)
@ -94,14 +94,19 @@ namespace OpenSim.Grid.AssetServer
LoadDefaultAssets();
m_log.Info("[ASSET]: Starting HTTP process");
BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort);
m_httpServer = new BaseHttpServer(m_config.HttpPort);
StatsManager.StartCollectingAssetStats();
httpServer.AddStreamHandler(new GetAssetStreamHandler(this, m_assetProvider));
httpServer.AddStreamHandler(new PostAssetStreamHandler(this, m_assetProvider));
AddHttpHandlers();
httpServer.Start();
m_httpServer.Start();
}
protected void AddHttpHandlers()
{
m_httpServer.AddStreamHandler(new GetAssetStreamHandler(this, m_assetProvider));
m_httpServer.AddStreamHandler(new PostAssetStreamHandler(this, m_assetProvider));
}
public byte[] GetAssetData(LLUUID assetID, bool isTexture)

View File

@ -45,14 +45,8 @@ namespace OpenSim.Grid.GridServer
{
protected GridConfig m_config;
protected GridManager m_gridManager;
protected BaseHttpServer httpServer;
protected List<IGridPlugin> m_plugins = new List<IGridPlugin>();
public BaseHttpServer HttpServer
{
get { return httpServer; }
}
public void Work()
{
m_console.Notice("Enter help for a list of commands\n");
@ -88,40 +82,39 @@ namespace OpenSim.Grid.GridServer
SetupGridManager();
m_console.Status("[GRID]: Starting HTTP process");
httpServer = new BaseHttpServer(m_config.HttpPort);
//GridManagementAgent GridManagerAgent = new GridManagementAgent(httpServer, "gridserver", m_config.SimSendKey, m_config.SimRecvKey, managercallback);
m_httpServer = new BaseHttpServer(m_config.HttpPort);
httpServer.AddXmlRPCHandler("simulator_login", m_gridManager.XmlRpcSimulatorLoginMethod);
httpServer.AddXmlRPCHandler("simulator_data_request", m_gridManager.XmlRpcSimulatorDataRequestMethod);
httpServer.AddXmlRPCHandler("simulator_after_region_moved", m_gridManager.XmlRpcDeleteRegionMethod);
httpServer.AddXmlRPCHandler("map_block", m_gridManager.XmlRpcMapBlockMethod);
AddHttpHandlers();
// Message Server ---> Grid Server
httpServer.AddXmlRPCHandler("register_messageserver", m_gridManager.XmlRPCRegisterMessageServer);
httpServer.AddXmlRPCHandler("deregister_messageserver", m_gridManager.XmlRPCDeRegisterMessageServer);
LoadGridPlugins( );
httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", m_gridManager.RestGetSimMethod));
httpServer.AddStreamHandler(new RestStreamHandler("POST", "/sims/", m_gridManager.RestSetSimMethod));
httpServer.AddStreamHandler(new RestStreamHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod));
httpServer.AddStreamHandler(new RestStreamHandler("POST", "/regions/", m_gridManager.RestSetRegionMethod));
//httpServer.AddRestHandler("GET", "/sims/", m_gridManager.RestGetSimMethod);
//httpServer.AddRestHandler("POST", "/sims/", m_gridManager.RestSetSimMethod);
//httpServer.AddRestHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod);
//httpServer.AddRestHandler("POST", "/regions/", m_gridManager.RestSetRegionMethod);
LoadGridPlugins();
httpServer.Start();
m_httpServer.Start();
m_console.Status("[GRID]: Starting sim status checker");
Timer simCheckTimer = new Timer(3600000*3); // 3 Hours between updates.
Timer simCheckTimer = new Timer(3600000 * 3); // 3 Hours between updates.
simCheckTimer.Elapsed += new ElapsedEventHandler(CheckSims);
simCheckTimer.Enabled = true;
}
protected void AddHttpHandlers()
{
m_httpServer.AddXmlRPCHandler("simulator_login", m_gridManager.XmlRpcSimulatorLoginMethod);
m_httpServer.AddXmlRPCHandler("simulator_data_request", m_gridManager.XmlRpcSimulatorDataRequestMethod);
m_httpServer.AddXmlRPCHandler("simulator_after_region_moved", m_gridManager.XmlRpcDeleteRegionMethod);
m_httpServer.AddXmlRPCHandler("map_block", m_gridManager.XmlRpcMapBlockMethod);
// Message Server ---> Grid Server
m_httpServer.AddXmlRPCHandler("register_messageserver", m_gridManager.XmlRPCRegisterMessageServer);
m_httpServer.AddXmlRPCHandler("deregister_messageserver", m_gridManager.XmlRPCDeRegisterMessageServer);
m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/sims/", m_gridManager.RestGetSimMethod));
m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/sims/", m_gridManager.RestSetSimMethod));
m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/regions/", m_gridManager.RestGetRegionMethod));
m_httpServer.AddStreamHandler(new RestStreamHandler("POST", "/regions/", m_gridManager.RestSetRegionMethod));
}
protected void LoadGridPlugins()
{
//m_console.Status("[GRIDPLUGINS]: Looking for plugins");
@ -131,8 +124,8 @@ namespace OpenSim.Grid.GridServer
ExtensionNodeList nodes = AddinManager.GetExtensionNodes("/OpenSim/GridServer");
foreach (TypeExtensionNode node in nodes)
{
m_console.Status("[GRIDPLUGINS]: Loading OpenSim plugin "+node.Path);
IGridPlugin plugin = (IGridPlugin) node.CreateInstance();
m_console.Status("[GRIDPLUGINS]: Loading OpenSim plugin " + node.Path);
IGridPlugin plugin = (IGridPlugin)node.CreateInstance();
plugin.Initialise(this);
m_plugins.Add(plugin);
}
@ -191,15 +184,15 @@ namespace OpenSim.Grid.GridServer
public override void RunCmd(string cmd, string[] cmdparams)
{
base.RunCmd(cmd, cmdparams);
switch (cmd)
{
case "help":
m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
break;
break;
case "shutdown":
foreach(IGridPlugin plugin in m_plugins) plugin.Close();
foreach (IGridPlugin plugin in m_plugins) plugin.Close();
m_console.Close();
Environment.Exit(0);
break;

View File

@ -72,36 +72,42 @@ namespace OpenSim.Grid.InventoryServer
m_inventoryService.AddPlugin(m_config.DatabaseProvider);
m_log.Info("[" + LogName + "]: Starting HTTP server ...");
BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort);
httpServer.AddStreamHandler(
m_httpServer = new BaseHttpServer(m_config.HttpPort);
AddHttpHandlers();
m_httpServer.Start();
m_log.Info("[" + LogName + "]: Started HTTP server");
}
protected void AddHttpHandlers()
{
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<Guid, InventoryCollection>("POST", "/GetInventory/",
m_inventoryService.GetUserInventory));
httpServer.AddStreamHandler(
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<Guid, bool>("POST", "/CreateInventory/",
m_inventoryService.CreateUsersInventory));
httpServer.AddStreamHandler(
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/NewFolder/",
m_inventoryService.AddInventoryFolder));
httpServer.AddStreamHandler(
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/MoveFolder/",
m_inventoryService.MoveInventoryFolder));
httpServer.AddStreamHandler(
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/NewItem/",
m_inventoryService.AddInventoryItem));
httpServer.AddStreamHandler(
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/DeleteItem/",
m_inventoryService.DeleteInvItem));
httpServer.AddStreamHandler(
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<Guid, List<InventoryFolderBase>>("POST", "/RootFolders/",
m_inventoryService.RequestFirstLevelFolders));
// httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager));
httpServer.Start();
m_log.Info("[" + LogName + "]: Started HTTP server");
}
private void Work()

View File

@ -44,9 +44,6 @@ namespace OpenSim.Grid.MessagingServer
private MessageServerConfig Cfg;
private MessageService msgsvc;
//public UserManager m_userManager;
//public UserLoginService m_loginService;
private LLUUID m_lastCreatedUser = LLUUID.Random();
@ -86,14 +83,14 @@ namespace OpenSim.Grid.MessagingServer
Cfg = new MessageServerConfig("MESSAGING SERVER", (Path.Combine(Util.configDir(), "MessagingServer_Config.xml")));
m_log.Info("[REGION]: Starting HTTP process");
BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort);
m_httpServer = new BaseHttpServer(Cfg.HttpPort);
msgsvc = new MessageService(Cfg);
if (msgsvc.registerWithUserServer())
{
httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn);
httpServer.AddXmlRPCHandler("logout_of_simulator", msgsvc.UserLoggedOff);
m_httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn);
m_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);
@ -106,7 +103,7 @@ namespace OpenSim.Grid.MessagingServer
//httpServer.AddStreamHandler(
//new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
httpServer.Start();
m_httpServer.Start();
m_log.Info("[SERVER]: Messageserver 0.5 - Startup complete");
}
else

View File

@ -100,35 +100,41 @@ namespace OpenSim.Grid.UserServer
m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
m_log.Info("[REGION]: Starting HTTP process");
BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort);
httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod);
httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin);
httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod);
m_httpServer = new BaseHttpServer(Cfg.HttpPort);
AddHttpHandlers();
m_httpServer.Start();
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);
httpServer.AddXmlRPCHandler("add_new_user_friend", m_userManager.XmlRpcResponseXmlRPCAddUserFriend);
httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend);
httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms);
httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList);
httpServer.AddXmlRPCHandler("logout_of_simulator", m_userManager.XmlRPCLogOffUserMethodUUID);
m_log.Info("[SERVER]: Userserver 0.5 - Startup complete");
}
protected void AddHttpHandlers()
{
m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod);
m_httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin);
m_httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod);
m_httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName);
m_httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID);
m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar);
m_httpServer.AddXmlRPCHandler("add_new_user_friend", m_userManager.XmlRpcResponseXmlRPCAddUserFriend);
m_httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend);
m_httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms);
m_httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList);
m_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);
m_httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer);
m_httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion);
m_httpServer.AddXmlRPCHandler("deregister_messageserver", m_messagesService.XmlRPCDeRegisterMessageServer);
httpServer.AddStreamHandler(
m_httpServer.AddStreamHandler(
new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
httpServer.AddXmlRPCHandler("update_user_profile", m_userManager.XmlRpcResponseXmlRPCUpdateUserProfile);
httpServer.Start();
m_log.Info("[SERVER]: Userserver 0.5 - Startup complete");
m_httpServer.AddXmlRPCHandler("update_user_profile", m_userManager.XmlRpcResponseXmlRPCUpdateUserProfile);
}
public void do_create(string what)
@ -239,28 +245,5 @@ namespace OpenSim.Grid.UserServer
m_messagesService.TellMessageServersAboutUser( agentID, sessionID, RegionID, regionhandle, positionX,
positionY, positionZ, firstname, lastname);
}
/*private void ConfigDB(IGenericConfig configData)
{
try
{
string attri = String.Empty;
attri = configData.GetAttribute("DataBaseProvider");
if (attri == String.Empty)
{
StorageDll = "OpenSim.Framework.Data.DB4o.dll";
configData.SetAttribute("DataBaseProvider", "OpenSim.Framework.Data.DB4o.dll");
}
else
{
StorageDll = attri;
}
configData.Commit();
}
catch
{
}
}*/
}
}