aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer/Main.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/UserServer/Main.cs')
-rw-r--r--OpenSim/Grid/UserServer/Main.cs167
1 files changed, 58 insertions, 109 deletions
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index e174b2d..63d788d 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -62,10 +62,12 @@ namespace OpenSim.Grid.UserServer
62 protected UserServerFriendsModule m_friendsModule; 62 protected UserServerFriendsModule m_friendsModule;
63 63
64 public UserLoginService m_loginService; 64 public UserLoginService m_loginService;
65 public GridInfoService m_gridInfoService;
66 public MessageServersConnector m_messagesService; 65 public MessageServersConnector m_messagesService;
67 66
67 protected GridInfoServiceModule m_gridInfoService;
68
68 protected UserServerCommandModule m_consoleCommandModule; 69 protected UserServerCommandModule m_consoleCommandModule;
70 protected UserServerEventDispatchModule m_eventDispatcher;
69 71
70 public static void Main(string[] args) 72 public static void Main(string[] args)
71 { 73 {
@@ -97,62 +99,40 @@ namespace OpenSim.Grid.UserServer
97 99
98 protected override void StartupSpecific() 100 protected override void StartupSpecific()
99 { 101 {
100 IInterServiceInventoryServices inventoryService = SetupRegisterCoreComponents(); 102 IInterServiceInventoryServices inventoryService = StartupCoreComponents();
101 103
102 m_stats = StatsManager.StartCollectingUserStats(); 104 m_stats = StatsManager.StartCollectingUserStats();
103 105
104 m_log.Info("[STARTUP]: Establishing data connection");
105 //setup database access service
106 m_userDataBaseService = new UserDataBaseService();
107 m_userDataBaseService.Initialise(this);
108
109 //setup services/modules 106 //setup services/modules
110 StartupUserServerModules(); 107 StartupUserServerModules();
111 108
112 StartOtherComponents(inventoryService); 109 StartOtherComponents(inventoryService);
113 110
114 m_consoleCommandModule = new UserServerCommandModule(m_loginService);
115 m_consoleCommandModule.Initialise(this);
116
117 //register event handlers
118 RegisterEventHandlers();
119
120 //PostInitialise the modules 111 //PostInitialise the modules
121 m_consoleCommandModule.PostInitialise(); //it will register its Console command handlers in here 112 PostInitialiseModules();
122 m_userDataBaseService.PostInitialise();
123 113
124 //register http handlers and start http server 114 //register http handlers and start http server
125 m_log.Info("[STARTUP]: Starting HTTP process"); 115 m_log.Info("[STARTUP]: Starting HTTP process");
126 RegisterHttpHandlers(); 116 RegisterHttpHandlers();
127 m_httpServer.Start(); 117 m_httpServer.Start();
128
129 base.StartupSpecific();
130 }
131
132 private void StartOtherComponents(IInterServiceInventoryServices inventoryService)
133 {
134 m_gridInfoService = new GridInfoService();
135
136 StartupLoginService(inventoryService);
137 //
138 // Get the minimum defaultLevel to access to the grid
139 //
140 m_loginService.setloginlevel((int)Cfg.DefaultUserLevel);
141 118
142 m_messagesService = new MessageServersConnector(); 119 base.StartupSpecific();
143 } 120 }
144 121
145 private IInterServiceInventoryServices SetupRegisterCoreComponents() 122 protected virtual IInterServiceInventoryServices StartupCoreComponents()
146 { 123 {
147 Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); 124 Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
148 125
149 IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl);
150
151 m_httpServer = new BaseHttpServer(Cfg.HttpPort); 126 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
152 127
153 RegisterInterface<ConsoleBase>(m_console); 128 RegisterInterface<ConsoleBase>(m_console);
154 RegisterInterface<UserConfig>(Cfg); 129 RegisterInterface<UserConfig>(Cfg);
130
131 IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl);
132 // IRegionProfileService regionProfileService = new RegionProfileServiceProxy();
133
155 RegisterInterface<IInterServiceInventoryServices>(inventoryService); 134 RegisterInterface<IInterServiceInventoryServices>(inventoryService);
135 // RegisterInterface<IRegionProfileService>(regionProfileService);
156 136
157 return inventoryService; 137 return inventoryService;
158 } 138 }
@@ -163,9 +143,43 @@ namespace OpenSim.Grid.UserServer
163 /// <param name="inventoryService"></param> 143 /// <param name="inventoryService"></param>
164 protected virtual void StartupUserServerModules() 144 protected virtual void StartupUserServerModules()
165 { 145 {
146 m_log.Info("[STARTUP]: Establishing data connection");
147 //setup database access service, for now this has to be created before the other modules.
148 m_userDataBaseService = new UserDataBaseService();
149 m_userDataBaseService.Initialise(this);
150
151 //TODO: change these modules so they fetch the databaseService class in the PostInitialise method
166 m_userManager = new UserManager(m_userDataBaseService); 152 m_userManager = new UserManager(m_userDataBaseService);
153 m_userManager.Initialise(this);
154
167 m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService); 155 m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService);
156 m_avatarAppearanceModule.Initialise(this);
157
168 m_friendsModule = new UserServerFriendsModule(m_userDataBaseService); 158 m_friendsModule = new UserServerFriendsModule(m_userDataBaseService);
159 m_friendsModule.Initialise(this);
160
161 m_consoleCommandModule = new UserServerCommandModule();
162 m_consoleCommandModule.Initialise(this);
163
164 m_messagesService = new MessageServersConnector();
165 m_messagesService.Initialise(this);
166
167 m_gridInfoService = new GridInfoServiceModule();
168 m_gridInfoService.Initialise(this);
169 }
170
171 protected virtual void StartOtherComponents(IInterServiceInventoryServices inventoryService)
172 {
173 StartupLoginService(inventoryService);
174 //
175 // Get the minimum defaultLevel to access to the grid
176 //
177 m_loginService.setloginlevel((int)Cfg.DefaultUserLevel);
178
179 RegisterInterface<UserLoginService>(m_loginService); //TODO: should be done in the login service
180
181 m_eventDispatcher = new UserServerEventDispatchModule(m_userManager, m_messagesService, m_loginService);
182 m_eventDispatcher.Initialise(this);
169 } 183 }
170 184
171 /// <summary> 185 /// <summary>
@@ -178,34 +192,32 @@ namespace OpenSim.Grid.UserServer
178 m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy()); 192 m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy());
179 } 193 }
180 194
181 protected virtual void RegisterEventHandlers() 195 protected virtual void PostInitialiseModules()
182 { 196 {
183 m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation; 197 m_consoleCommandModule.PostInitialise(); //it will register its Console command handlers in here
184 m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff; 198 m_userDataBaseService.PostInitialise();
185 199 m_messagesService.PostInitialise();
186 m_messagesService.OnAgentLocation += HandleAgentLocation; 200 m_eventDispatcher.PostInitialise(); //it will register event handlers in here
187 m_messagesService.OnAgentLeaving += HandleAgentLeaving; 201 m_gridInfoService.PostInitialise();
188 m_messagesService.OnRegionStartup += HandleRegionStartup; 202 m_userManager.PostInitialise();
189 m_messagesService.OnRegionShutdown += HandleRegionShutdown; 203 m_avatarAppearanceModule.PostInitialise();
204 m_friendsModule.PostInitialise();
190 } 205 }
191 206
192 protected virtual void RegisterHttpHandlers() 207 protected virtual void RegisterHttpHandlers()
193 { 208 {
194 m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true); 209 m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true);
195 210
196 m_userManager.RegisterHandlers(m_httpServer); 211 m_userManager.RegisterHandlers(m_httpServer);
197 m_friendsModule.RegisterHandlers(m_httpServer); 212 m_friendsModule.RegisterHandlers(m_httpServer);
198 m_avatarAppearanceModule.RegisterHandlers(m_httpServer); 213 m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
199 m_messagesService.RegisterHandlers(m_httpServer); 214 m_messagesService.RegisterHandlers(m_httpServer);
200 215 m_gridInfoService.RegisterHandlers(m_httpServer);
201 m_httpServer.AddStreamHandler(new RestStreamHandler("GET", "/get_grid_info",
202 m_gridInfoService.RestGetGridInfoMethod));
203 m_httpServer.AddXmlRPCHandler("get_grid_info", m_gridInfoService.XmlRpcGridInfoMethod);
204 } 216 }
205 217
206 public override void ShutdownSpecific() 218 public override void ShutdownSpecific()
207 { 219 {
208 m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation; 220 m_eventDispatcher.Close();
209 } 221 }
210 222
211 #region IUGAIMCore 223 #region IUGAIMCore
@@ -247,74 +259,11 @@ namespace OpenSim.Grid.UserServer
247 { 259 {
248 return m_httpServer; 260 return m_httpServer;
249 } 261 }
250
251
252 #endregion
253
254 #region Console Command Handlers
255
256 protected override void ShowHelp(string[] helpArgs)
257 {
258 base.ShowHelp(helpArgs);
259 }
260 #endregion 262 #endregion
261 263
262 public void TestResponse(List<InventoryFolderBase> resp) 264 public void TestResponse(List<InventoryFolderBase> resp)
263 { 265 {
264 m_console.Notice("response got"); 266 m_console.Notice("response got");
265 } 267 }
266
267 #region Event Handlers
268 public void NotifyMessageServersUserLoggOff(UUID agentID)
269 {
270 m_messagesService.TellMessageServersAboutUserLogoff(agentID);
271 }
272
273 public void NotifyMessageServersUserLoggedInToLocation(UUID agentID, UUID sessionID, UUID RegionID,
274 ulong regionhandle, float positionX, float positionY,
275 float positionZ, string firstname, string lastname)
276 {
277 m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX,
278 positionY, positionZ, firstname, lastname);
279 }
280
281 public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle)
282 {
283 m_userManager.HandleAgentLocation(agentID, regionID, regionHandle);
284 }
285
286 public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
287 {
288 m_userManager.HandleAgentLeaving(agentID, regionID, regionHandle);
289 }
290
291 public void HandleRegionStartup(UUID regionID)
292 {
293 // This might seem strange, that we send this back to the
294 // server it came from. But there is method to the madness.
295 // There can be multiple user servers on the same database,
296 // and each can have multiple messaging servers. So, we send
297 // it to all known user servers, who send it to all known
298 // message servers. That way, we should be able to finally
299 // update presence to all regions and thereby all friends
300 //
301 m_userManager.HandleRegionStartup(regionID);
302 m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
303 }
304
305 public void HandleRegionShutdown(UUID regionID)
306 {
307 // This might seem strange, that we send this back to the
308 // server it came from. But there is method to the madness.
309 // There can be multiple user servers on the same database,
310 // and each can have multiple messaging servers. So, we send
311 // it to all known user servers, who send it to all known
312 // message servers. That way, we should be able to finally
313 // update presence to all regions and thereby all friends
314 //
315 m_userManager.HandleRegionShutdown(regionID);
316 m_messagesService.TellMessageServersAboutRegionShutdown(regionID);
317 }
318 #endregion
319 } 268 }
320} 269}