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.cs330
1 files changed, 0 insertions, 330 deletions
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
deleted file mode 100644
index 286076d7..0000000
--- a/OpenSim/Grid/UserServer/Main.cs
+++ /dev/null
@@ -1,330 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using log4net;
33using log4net.Config;
34using OpenMetaverse;
35using OpenSim.Data;
36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Console;
40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Framework.Statistics;
43using OpenSim.Grid.Communications.OGS1;
44using OpenSim.Grid.Framework;
45using OpenSim.Grid.UserServer.Modules;
46using Nini.Config;
47
48namespace OpenSim.Grid.UserServer
49{
50 /// <summary>
51 /// Grid user server main class
52 /// </summary>
53 public class OpenUser_Main : BaseOpenSimServer, IGridServiceCore
54 {
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56
57 protected UserConfig Cfg;
58
59 protected UserDataBaseService m_userDataBaseService;
60
61 public UserManager m_userManager;
62
63 protected UserServerAvatarAppearanceModule m_avatarAppearanceModule;
64 protected UserServerFriendsModule m_friendsModule;
65
66 public UserLoginService m_loginService;
67 public UserLoginAuthService m_loginAuthService;
68 public MessageServersConnector m_messagesService;
69
70 protected GridInfoServiceModule m_gridInfoService;
71
72 protected UserServerCommandModule m_consoleCommandModule;
73 protected UserServerEventDispatchModule m_eventDispatcher;
74
75 protected AvatarCreationModule m_appearanceModule;
76
77 protected static string m_consoleType = "local";
78 protected static IConfigSource m_config = null;
79 protected static string m_configFile = "UserServer_Config.xml";
80
81 public static void Main(string[] args)
82 {
83 ArgvConfigSource argvSource = new ArgvConfigSource(args);
84 argvSource.AddSwitch("Startup", "console", "c");
85 argvSource.AddSwitch("Startup", "xmlfile", "x");
86
87 IConfig startupConfig = argvSource.Configs["Startup"];
88 if (startupConfig != null)
89 {
90 m_consoleType = startupConfig.GetString("console", "local");
91 m_configFile = startupConfig.GetString("xmlfile", "UserServer_Config.xml");
92 }
93
94 m_config = argvSource;
95
96 XmlConfigurator.Configure();
97
98 m_log.Info("Launching UserServer...");
99
100 OpenUser_Main userserver = new OpenUser_Main();
101
102 userserver.Startup();
103 userserver.Work();
104 }
105
106 public OpenUser_Main()
107 {
108 switch (m_consoleType)
109 {
110 case "rest":
111 m_console = new RemoteConsole("User");
112 break;
113 case "basic":
114 m_console = new CommandConsole("User");
115 break;
116 default:
117 m_console = new LocalConsole("User");
118 break;
119 }
120 MainConsole.Instance = m_console;
121 }
122
123 public void Work()
124 {
125 m_console.Output("Enter help for a list of commands\n");
126
127 while (true)
128 {
129 m_console.Prompt();
130 }
131 }
132
133 protected override void StartupSpecific()
134 {
135 IInterServiceInventoryServices inventoryService = StartupCoreComponents();
136
137 m_stats = StatsManager.StartCollectingUserStats();
138
139 //setup services/modules
140 StartupUserServerModules();
141
142 StartOtherComponents(inventoryService);
143
144 //PostInitialise the modules
145 PostInitialiseModules();
146
147 //register http handlers and start http server
148 m_log.Info("[STARTUP]: Starting HTTP process");
149 RegisterHttpHandlers();
150 m_httpServer.Start();
151
152 base.StartupSpecific();
153 }
154
155 protected virtual IInterServiceInventoryServices StartupCoreComponents()
156 {
157 Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), m_configFile)));
158
159 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
160
161 if (m_console is RemoteConsole)
162 {
163 RemoteConsole c = (RemoteConsole)m_console;
164 c.SetServer(m_httpServer);
165 IConfig netConfig = m_config.AddConfig("Network");
166 netConfig.Set("ConsoleUser", Cfg.ConsoleUser);
167 netConfig.Set("ConsolePass", Cfg.ConsolePass);
168 c.ReadConfig(m_config);
169 }
170
171 RegisterInterface<CommandConsole>(m_console);
172 RegisterInterface<UserConfig>(Cfg);
173
174 //Should be in modules?
175 IInterServiceInventoryServices inventoryService = new OGS1InterServiceInventoryService(Cfg.InventoryUrl);
176 // IRegionProfileRouter regionProfileService = new RegionProfileServiceProxy();
177
178 RegisterInterface<IInterServiceInventoryServices>(inventoryService);
179 // RegisterInterface<IRegionProfileRouter>(regionProfileService);
180
181 return inventoryService;
182 }
183
184 /// <summary>
185 /// Start up the user manager
186 /// </summary>
187 /// <param name="inventoryService"></param>
188 protected virtual void StartupUserServerModules()
189 {
190 m_log.Info("[STARTUP]: Establishing data connection");
191
192 //we only need core components so we can request them from here
193 IInterServiceInventoryServices inventoryService;
194 TryGet<IInterServiceInventoryServices>(out inventoryService);
195
196 CommunicationsManager commsManager = new UserServerCommsManager(inventoryService);
197
198 //setup database access service, for now this has to be created before the other modules.
199 m_userDataBaseService = new UserDataBaseService(commsManager);
200 m_userDataBaseService.Initialise(this);
201
202 //TODO: change these modules so they fetch the databaseService class in the PostInitialise method
203 m_userManager = new UserManager(m_userDataBaseService);
204 m_userManager.Initialise(this);
205
206 m_avatarAppearanceModule = new UserServerAvatarAppearanceModule(m_userDataBaseService);
207 m_avatarAppearanceModule.Initialise(this);
208
209 m_friendsModule = new UserServerFriendsModule(m_userDataBaseService);
210 m_friendsModule.Initialise(this);
211
212 m_consoleCommandModule = new UserServerCommandModule();
213 m_consoleCommandModule.Initialise(this);
214
215 m_messagesService = new MessageServersConnector();
216 m_messagesService.Initialise(this);
217
218 m_gridInfoService = new GridInfoServiceModule();
219 m_gridInfoService.Initialise(this);
220 }
221
222 protected virtual void StartOtherComponents(IInterServiceInventoryServices inventoryService)
223 {
224 m_appearanceModule = new AvatarCreationModule(m_userDataBaseService, Cfg, inventoryService);
225 m_appearanceModule.Initialise(this);
226
227 StartupLoginService(inventoryService);
228 //
229 // Get the minimum defaultLevel to access to the grid
230 //
231 m_loginService.setloginlevel((int)Cfg.DefaultUserLevel);
232
233 RegisterInterface<UserLoginService>(m_loginService); //TODO: should be done in the login service
234
235 m_eventDispatcher = new UserServerEventDispatchModule(m_userManager, m_messagesService, m_loginService);
236 m_eventDispatcher.Initialise(this);
237 }
238
239 /// <summary>
240 /// Start up the login service
241 /// </summary>
242 /// <param name="inventoryService"></param>
243 protected virtual void StartupLoginService(IInterServiceInventoryServices inventoryService)
244 {
245 m_loginService = new UserLoginService(
246 m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile), Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy());
247
248 if (Cfg.EnableHGLogin)
249 m_loginAuthService = new UserLoginAuthService(m_userDataBaseService, inventoryService, new LibraryRootFolder(Cfg.LibraryXmlfile),
250 Cfg, Cfg.DefaultStartupMsg, new RegionProfileServiceProxy());
251 }
252
253 protected virtual void PostInitialiseModules()
254 {
255 m_consoleCommandModule.PostInitialise(); //it will register its Console command handlers in here
256 m_userDataBaseService.PostInitialise();
257 m_messagesService.PostInitialise();
258 m_eventDispatcher.PostInitialise(); //it will register event handlers in here
259 m_gridInfoService.PostInitialise();
260 m_userManager.PostInitialise();
261 m_avatarAppearanceModule.PostInitialise();
262 m_friendsModule.PostInitialise();
263 }
264
265 protected virtual void RegisterHttpHandlers()
266 {
267 m_loginService.RegisterHandlers(m_httpServer, Cfg.EnableLLSDLogin, true);
268
269 if (m_loginAuthService != null)
270 m_loginAuthService.RegisterHandlers(m_httpServer);
271
272 m_userManager.RegisterHandlers(m_httpServer);
273 m_friendsModule.RegisterHandlers(m_httpServer);
274 m_avatarAppearanceModule.RegisterHandlers(m_httpServer);
275 m_messagesService.RegisterHandlers(m_httpServer);
276 m_gridInfoService.RegisterHandlers(m_httpServer);
277 }
278
279 public override void ShutdownSpecific()
280 {
281 m_eventDispatcher.Close();
282 }
283
284 #region IUGAIMCore
285 protected Dictionary<Type, object> m_moduleInterfaces = new Dictionary<Type, object>();
286
287 /// <summary>
288 /// Register an Module interface.
289 /// </summary>
290 /// <typeparam name="T"></typeparam>
291 /// <param name="iface"></param>
292 public void RegisterInterface<T>(T iface)
293 {
294 lock (m_moduleInterfaces)
295 {
296 if (!m_moduleInterfaces.ContainsKey(typeof(T)))
297 {
298 m_moduleInterfaces.Add(typeof(T), iface);
299 }
300 }
301 }
302
303 public bool TryGet<T>(out T iface)
304 {
305 if (m_moduleInterfaces.ContainsKey(typeof(T)))
306 {
307 iface = (T)m_moduleInterfaces[typeof(T)];
308 return true;
309 }
310 iface = default(T);
311 return false;
312 }
313
314 public T Get<T>()
315 {
316 return (T)m_moduleInterfaces[typeof(T)];
317 }
318
319 public BaseHttpServer GetHttpServer()
320 {
321 return m_httpServer;
322 }
323 #endregion
324
325 public void TestResponse(List<InventoryFolderBase> resp)
326 {
327 m_console.Output("response got");
328 }
329 }
330}