aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer/Main.cs
diff options
context:
space:
mode:
authorMW2009-02-24 13:33:57 +0000
committerMW2009-02-24 13:33:57 +0000
commit2a91f21d082aee4dc97b5b0d29e1739cfe409024 (patch)
tree950cf659d45ffc05367814c0075b48f4a2aabbc5 /OpenSim/Grid/UserServer/Main.cs
parentupdate version number for bamboo zip file output (diff)
downloadopensim-SC_OLD-2a91f21d082aee4dc97b5b0d29e1739cfe409024.zip
opensim-SC_OLD-2a91f21d082aee4dc97b5b0d29e1739cfe409024.tar.gz
opensim-SC_OLD-2a91f21d082aee4dc97b5b0d29e1739cfe409024.tar.bz2
opensim-SC_OLD-2a91f21d082aee4dc97b5b0d29e1739cfe409024.tar.xz
More refactoring of the UserServer.
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/UserServer/Main.cs179
1 files changed, 105 insertions, 74 deletions
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 1e6504d..efa090e 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Grid.UserServer
46 /// <summary> 46 /// <summary>
47 /// Grid user server main class 47 /// Grid user server main class
48 /// </summary> 48 /// </summary>
49 public class OpenUser_Main : BaseOpenSimServer 49 public class OpenUser_Main : BaseOpenSimServer, IUGAIMCore
50 { 50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 52
@@ -55,6 +55,10 @@ namespace OpenSim.Grid.UserServer
55 protected UserDataBaseService m_userDataBaseService; 55 protected UserDataBaseService m_userDataBaseService;
56 56
57 public UserManager m_userManager; 57 public UserManager m_userManager;
58
59 protected UserServerAvatarAppearanceModule m_avatarAppearanceModule;
60 protected UserServerFriendsModule m_friendsModule;
61
58 public UserLoginService m_loginService; 62 public UserLoginService m_loginService;
59 public GridInfoService m_gridInfoService; 63 public GridInfoService m_gridInfoService;
60 public MessageServersConnector m_messagesService; 64 public MessageServersConnector m_messagesService;
@@ -99,17 +103,64 @@ namespace OpenSim.Grid.UserServer
99 103
100 IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl); 104 IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl);
101 105
106 //setup database access service
102 m_userDataBaseService = new UserDataBaseService(inventoryService); 107 m_userDataBaseService = new UserDataBaseService(inventoryService);
103 m_userDataBaseService.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect); 108 m_userDataBaseService.AddPlugin(Cfg.DatabaseProvider, Cfg.DatabaseConnect);
104 109
105 StartupUserManager(inventoryService); 110 //Register the database access service so modules can fetch it
111 // RegisterInterface<UserDataBaseService>(m_userDataBaseService);
112
113 //setup services/modules
114 StartupUserServerModules();
106 115
107 m_gridInfoService = new GridInfoService(); 116 m_gridInfoService = new GridInfoService();
108 117
109 StartupLoginService(inventoryService); 118 StartupLoginService(inventoryService);
119 //
120 // Get the minimum defaultLevel to access to the grid
121 //
122 m_loginService.setloginlevel((int)Cfg.DefaultUserLevel);
110 123
111 m_messagesService = new MessageServersConnector(); 124 m_messagesService = new MessageServersConnector();
112 125
126 //register event handlers
127 RegisterEventHandlers();
128
129 //register http handlers and start http server
130 m_log.Info("[STARTUP]: Starting HTTP process");
131 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
132 RegisterHttpHandlers();
133 m_httpServer.Start();
134
135 base.StartupSpecific();
136
137 //register Console command handlers
138 RegisterConsoleCommands();
139 }
140
141 /// <summary>
142 /// Start up the user manager
143 /// </summary>
144 /// <param name="inventoryService"></param>
145 protected virtual void StartupUserServerModules()
146 {
147 m_userManager = new UserManager(m_userDataBaseService);
148 m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService);
149 m_friendsModule = new UserServerFriendsModule(m_userDataBaseService);
150 }
151
152 /// <summary>
153 /// Start up the login service
154 /// </summary>
155 /// <param name="inventoryService"></param>
156 protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService)
157 {
158 m_loginService = new UserLoginService(
159 m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy());
160 }
161
162 protected virtual void RegisterEventHandlers()
163 {
113 m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation; 164 m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
114 m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff; 165 m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
115 166
@@ -117,15 +168,10 @@ namespace OpenSim.Grid.UserServer
117 m_messagesService.OnAgentLeaving += HandleAgentLeaving; 168 m_messagesService.OnAgentLeaving += HandleAgentLeaving;
118 m_messagesService.OnRegionStartup += HandleRegionStartup; 169 m_messagesService.OnRegionStartup += HandleRegionStartup;
119 m_messagesService.OnRegionShutdown += HandleRegionShutdown; 170 m_messagesService.OnRegionShutdown += HandleRegionShutdown;
171 }
120 172
121 m_log.Info("[STARTUP]: Starting HTTP process"); 173 protected virtual void RegisterConsoleCommands()
122 174 {
123 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
124 AddHttpHandlers();
125 m_httpServer.Start();
126
127 base.StartupSpecific();
128
129 m_console.Commands.AddCommand("userserver", false, "create user", 175 m_console.Commands.AddCommand("userserver", false, "create user",
130 "create user [<first> [<last> [<x> <y> [email]]]]", 176 "create user [<first> [<last> [<x> <y> [email]]]]",
131 "Create a new user account", RunCommand); 177 "Create a new user account", RunCommand);
@@ -156,80 +202,67 @@ namespace OpenSim.Grid.UserServer
156 "Log off a named user", RunCommand); 202 "Log off a named user", RunCommand);
157 } 203 }
158 204
159 /// <summary> 205 protected virtual void RegisterHttpHandlers()
160 /// Start up the user manager
161 /// </summary>
162 /// <param name="inventoryService"></param>
163 protected virtual void StartupUserManager(IInterServiceInventoryServices inventoryService)
164 { 206 {
165 m_userManager = new UserManager(inventoryService, m_userDataBaseService); 207 m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true);
208
209 m_userManager.RegisterHandlers(m_httpServer);
210 m_friendsModule.RegisterHandlers(m_httpServer);
211 m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
212 m_messagesService.RegisterHandlers(m_httpServer);
213
214 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info",
215 m_gridInfoService.RestGetGridInfoMethod));
216 m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);
166 } 217 }
167 218
219 public override void ShutdownSpecific()
220 {
221 m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
222 }
223
224 #region IUGAIMCore
225 private readonly Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
226
168 /// <summary> 227 /// <summary>
169 /// Start up the login service 228 /// Register an Module interface.
170 /// </summary> 229 /// </summary>
171 /// <param name="inventoryService"></param> 230 /// <typeparam name="T"></typeparam>
172 protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService) 231 /// <param name="iface"></param>
232 public void RegisterInterface<T>(T iface)
173 { 233 {
174 m_loginService = new UserLoginService( 234 lock (m_moduleInterfaces)
175 m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); 235 {
236 if (!m_moduleInterfaces.ContainsKey(typeof(T)))
237 {
238 m_moduleInterfaces.Add(typeof(T), iface);
239 }
240 }
176 } 241 }
177 242
178 protected virtual void AddHttpHandlers() 243 public bool TryGet<T>(out T iface)
179 { 244 {
180 m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); 245 if (m_moduleInterfaces.ContainsKey(typeof(T)))
181
182 m_httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin);
183 //
184 // Get the minimum defaultLevel to access to the grid
185 //
186 m_loginService.setloginlevel((int)Cfg.DefaultUserLevel);
187
188 if (Cfg.EnableLLSDLogin)
189 { 246 {
190 m_httpServer.SetDefaultLLSDHandler(m_loginService.LLSDLoginMethod); 247 iface = (T)m_moduleInterfaces[typeof(T)];
248 return true;
191 } 249 }
250 iface = default(T);
251 return false;
252 }
192 253
193 m_httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); 254 public T Get<T>()
194 m_httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID); 255 {
195 m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar); 256 return (T)m_moduleInterfaces[typeof(T)];
196 m_httpServer.AddXmlRPCHandler("add_new_user_friend", m_userManager.XmlRpcResponseXmlRPCAddUserFriend); 257 }
197 m_httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend);
198 m_httpServer.AddXmlRPCHandler("update_user_friend_perms",
199 m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms);
200 m_httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList);
201 m_httpServer.AddXmlRPCHandler("get_avatar_appearance", m_userManager.XmlRPCGetAvatarAppearance);
202 m_httpServer.AddXmlRPCHandler("update_avatar_appearance", m_userManager.XmlRPCUpdateAvatarAppearance);
203 m_httpServer.AddXmlRPCHandler("update_user_current_region", m_userManager.XmlRPCAtRegion);
204 m_httpServer.AddXmlRPCHandler("logout_of_simulator", m_userManager.XmlRPCLogOffUserMethodUUID);
205 m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", m_userManager.XmlRPCGetAgentMethodUUID);
206 m_httpServer.AddXmlRPCHandler("check_auth_session", m_userManager.XmlRPCCheckAuthSession);
207 m_httpServer.AddXmlRPCHandler("set_login_params", m_loginService.XmlRPCSetLoginParams);
208 m_httpServer.AddXmlRPCHandler("region_startup", m_messagesService.RegionStartup);
209 m_httpServer.AddXmlRPCHandler("region_shutdown", m_messagesService.RegionShutdown);
210 m_httpServer.AddXmlRPCHandler("agent_location", m_messagesService.AgentLocation);
211 m_httpServer.AddXmlRPCHandler("agent_leaving", m_messagesService.AgentLeaving);
212 // Message Server ---> User Server
213 m_httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer);
214 m_httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion);
215 m_httpServer.AddXmlRPCHandler("deregister_messageserver", m_messagesService.XmlRPCDeRegisterMessageServer);
216
217 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info",
218 m_gridInfoService.RestGetGridInfoMethod));
219 m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);
220
221 m_httpServer.AddStreamHandler(
222 new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
223
224 m_httpServer.AddXmlRPCHandler("update_user_profile", m_userManager.XmlRpcResponseXmlRPCUpdateUserProfile);
225 258
226 // Handler for OpenID avatar identity pages 259 public BaseHttpServer GetHttpServer()
227 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/users/", m_loginService)); 260 {
228 // Handlers for the OpenID endpoint server 261 return m_httpServer;
229 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("POST", "/openid/server/", m_loginService));
230 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/openid/server/", m_loginService));
231 } 262 }
263 #endregion
232 264
265 #region Console Command Handlers
233 public void do_create(string[] args) 266 public void do_create(string[] args)
234 { 267 {
235 switch (args[0]) 268 switch (args[0])
@@ -468,19 +501,16 @@ namespace OpenSim.Grid.UserServer
468 m_console.Notice("login-level <value> - Set the miminim userlevel allowed To login."); 501 m_console.Notice("login-level <value> - Set the miminim userlevel allowed To login.");
469 m_console.Notice("login-reset - reset the login level to its default value."); 502 m_console.Notice("login-reset - reset the login level to its default value.");
470 m_console.Notice("login-text <text to print during the login>"); 503 m_console.Notice("login-text <text to print during the login>");
471
472 }
473 504
474 public override void ShutdownSpecific()
475 {
476 m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
477 } 505 }
506 #endregion
478 507
479 public void TestResponse(List<InventoryFolderBase> resp) 508 public void TestResponse(List<InventoryFolderBase> resp)
480 { 509 {
481 m_console.Notice("response got"); 510 m_console.Notice("response got");
482 } 511 }
483 512
513 #region Event Handlers
484 public void NotifyMessageServersUserLoggOff(UUID agentID) 514 public void NotifyMessageServersUserLoggOff(UUID agentID)
485 { 515 {
486 m_messagesService.TellMessageServersAboutUserLogoff(agentID); 516 m_messagesService.TellMessageServersAboutUserLogoff(agentID);
@@ -531,5 +561,6 @@ namespace OpenSim.Grid.UserServer
531 m_userManager.HandleRegionShutdown(regionID); 561 m_userManager.HandleRegionShutdown(regionID);
532 m_messagesService.TellMessageServersAboutRegionShutdown(regionID); 562 m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
533 } 563 }
564 #endregion
534 } 565 }
535} 566}