* Refactored out common http handler operations
parent
ca718b6f8d
commit
7f11079f57
|
@ -38,6 +38,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()
|
||||
{
|
||||
m_startuptime = DateTime.Now;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
@ -199,7 +192,7 @@ namespace OpenSim.Grid.GridServer
|
|||
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;
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -45,9 +45,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();
|
||||
|
||||
[STAThread]
|
||||
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
m_httpServer = new BaseHttpServer(Cfg.HttpPort);
|
||||
AddHttpHandlers();
|
||||
m_httpServer.Start();
|
||||
|
||||
httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin);
|
||||
m_log.Info("[SERVER]: Userserver 0.5 - Startup complete");
|
||||
}
|
||||
|
||||
httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod);
|
||||
protected void AddHttpHandlers()
|
||||
{
|
||||
m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod);
|
||||
|
||||
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_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
|
||||
{
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue