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.cs145
1 files changed, 73 insertions, 72 deletions
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 0534e3b..25e1585 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -48,12 +48,61 @@ namespace OpenSim.Grid.UserServer
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 private UserConfig Cfg; 50 private UserConfig Cfg;
51 51 private LLUUID m_lastCreatedUser = LLUUID.Random();
52 public UserManager m_userManager; 52
53 public UserLoginService m_loginService; 53 public UserLoginService m_loginService;
54 public MessageServersConnector m_messagesService; 54 public MessageServersConnector m_messagesService;
55 public UserManager m_userManager;
55 56
56 private LLUUID m_lastCreatedUser = LLUUID.Random(); 57 private OpenUser_Main()
58 {
59 m_console = new ConsoleBase("OpenUser", this);
60 MainConsole.Instance = m_console;
61 }
62
63 #region conscmd_callback Members
64
65 public override void RunCmd(string cmd, string[] cmdparams)
66 {
67 base.RunCmd(cmd, cmdparams);
68
69 switch (cmd)
70 {
71 case "help":
72 m_console.Notice("create user - create a new user");
73 m_console.Notice("stats - statistical information for this server");
74 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
75 break;
76
77 case "create":
78 do_create(cmdparams[0]);
79 break;
80
81 case "shutdown":
82 m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
83 m_console.Close();
84 Environment.Exit(0);
85 break;
86
87 case "stats":
88 m_console.Notice(StatsManager.UserStats.Report());
89 break;
90
91 case "test-inventory":
92 // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
93 // requester.ReturnResponseVal = TestResponse;
94 // requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
95 SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST",
96 m_userManager.
97 _config.
98 InventoryUrl +
99 "RootFolders/",
100 m_lastCreatedUser);
101 break;
102 }
103 }
104
105 #endregion
57 106
58 [STAThread] 107 [STAThread]
59 public static void Main(string[] args) 108 public static void Main(string[] args)
@@ -68,12 +117,6 @@ namespace OpenSim.Grid.UserServer
68 userserver.Work(); 117 userserver.Work();
69 } 118 }
70 119
71 private OpenUser_Main()
72 {
73 m_console = new ConsoleBase("OpenUser", this);
74 MainConsole.Instance = m_console;
75 }
76
77 private void Work() 120 private void Work()
78 { 121 {
79 m_console.Notice("Enter help for a list of commands\n"); 122 m_console.Notice("Enter help for a list of commands\n");
@@ -87,16 +130,16 @@ namespace OpenSim.Grid.UserServer
87 public void Startup() 130 public void Startup()
88 { 131 {
89 Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml"))); 132 Cfg = new UserConfig("USER SERVER", (Path.Combine(Util.configDir(), "UserServer_Config.xml")));
90 133
91 StatsManager.StartCollectingUserStats(); 134 StatsManager.StartCollectingUserStats();
92 135
93 m_log.Info("[REGION]: Establishing data connection"); 136 m_log.Info("[REGION]: Establishing data connection");
94 m_userManager = new UserManager(); 137 m_userManager = new UserManager();
95 m_userManager._config = Cfg; 138 m_userManager._config = Cfg;
96 m_userManager.AddPlugin(Cfg.DatabaseProvider); 139 m_userManager.AddPlugin(Cfg.DatabaseProvider);
97 140
98 m_loginService = new UserLoginService( 141 m_loginService = new UserLoginService(
99 m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); 142 m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg);
100 143
101 m_messagesService = new MessageServersConnector(); 144 m_messagesService = new MessageServersConnector();
102 145
@@ -104,7 +147,7 @@ namespace OpenSim.Grid.UserServer
104 m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff; 147 m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
105 148
106 m_log.Info("[REGION]: Starting HTTP process"); 149 m_log.Info("[REGION]: Starting HTTP process");
107 150
108 m_httpServer = new BaseHttpServer(Cfg.HttpPort); 151 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
109 AddHttpHandlers(); 152 AddHttpHandlers();
110 m_httpServer.Start(); 153 m_httpServer.Start();
@@ -117,7 +160,7 @@ namespace OpenSim.Grid.UserServer
117 m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); 160 m_httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod);
118 161
119 m_httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin); 162 m_httpServer.AddHTTPHandler("login", m_loginService.ProcessHTMLLogin);
120 163
121 m_httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod); 164 m_httpServer.SetLLSDHandler(m_loginService.LLSDLoginMethod);
122 165
123 m_httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); 166 m_httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName);
@@ -128,7 +171,7 @@ namespace OpenSim.Grid.UserServer
128 m_httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms); 171 m_httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms);
129 m_httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList); 172 m_httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList);
130 m_httpServer.AddXmlRPCHandler("logout_of_simulator", m_userManager.XmlRPCLogOffUserMethodUUID); 173 m_httpServer.AddXmlRPCHandler("logout_of_simulator", m_userManager.XmlRPCLogOffUserMethodUUID);
131 174
132 // Message Server ---> User Server 175 // Message Server ---> User Server
133 m_httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer); 176 m_httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer);
134 m_httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion); 177 m_httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion);
@@ -163,17 +206,17 @@ namespace OpenSim.Grid.UserServer
163 { 206 {
164 m_log.ErrorFormat( 207 m_log.ErrorFormat(
165 "[USERS]: A user with the name {0} {1} already exists!", tempfirstname, templastname); 208 "[USERS]: A user with the name {0} {1} already exists!", tempfirstname, templastname);
166 209
167 break; 210 break;
168 } 211 }
169 212
170 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty); 213 tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + String.Empty);
171 214
172 LLUUID userID = new LLUUID(); 215 LLUUID userID = new LLUUID();
173 try 216 try
174 { 217 {
175 userID = m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); 218 userID = m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
176 } 219 }
177 catch (Exception ex) 220 catch (Exception ex)
178 { 221 {
179 m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString()); 222 m_log.ErrorFormat("[USERS]: Error creating user: {0}", ex.ToString());
@@ -181,72 +224,31 @@ namespace OpenSim.Grid.UserServer
181 224
182 try 225 try
183 { 226 {
184 bool created 227 bool created
185 = SynchronousRestObjectPoster.BeginPostObject<Guid, bool>( 228 = SynchronousRestObjectPoster.BeginPostObject<Guid, bool>(
186 "POST", m_userManager._config.InventoryUrl + "CreateInventory/", userID.UUID); 229 "POST", m_userManager._config.InventoryUrl + "CreateInventory/", userID.UUID);
187 230
188 if (!created) 231 if (!created)
189 { 232 {
190 throw new Exception( 233 throw new Exception(
191 String.Format( 234 String.Format(
192 "The inventory creation request for user {0} did not succeed." 235 "The inventory creation request for user {0} did not succeed."
193 + " Please contact your inventory service provider for more information.", 236 + " Please contact your inventory service provider for more information.",
194 userID)); 237 userID));
195 } 238 }
196
197 } 239 }
198 catch (WebException e) 240 catch (WebException e)
199 { 241 {
200 m_log.ErrorFormat( 242 m_log.ErrorFormat(
201 "[USERS]: Could not contact the inventory service at {0} to create an inventory for {1}", 243 "[USERS]: Could not contact the inventory service at {0} to create an inventory for {1}",
202 m_userManager._config.InventoryUrl + "CreateInventory/", userID.UUID); 244 m_userManager._config.InventoryUrl + "CreateInventory/", userID.UUID);
203 } 245 }
204 catch (Exception e) 246 catch (Exception e)
205 { 247 {
206 m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", e); 248 m_log.ErrorFormat("[USERS]: Error creating inventory for user: {0}", e);
207 } 249 }
208
209 m_lastCreatedUser = userID;
210 break;
211 }
212 }
213 250
214 public override void RunCmd(string cmd, string[] cmdparams) 251 m_lastCreatedUser = userID;
215 {
216 base.RunCmd(cmd, cmdparams);
217
218 switch (cmd)
219 {
220 case "help":
221 m_console.Notice("create user - create a new user");
222 m_console.Notice("stats - statistical information for this server");
223 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
224 break;
225
226 case "create":
227 do_create(cmdparams[0]);
228 break;
229
230 case "shutdown":
231 m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
232 m_console.Close();
233 Environment.Exit(0);
234 break;
235
236 case "stats":
237 m_console.Notice(StatsManager.UserStats.Report());
238 break;
239
240 case "test-inventory":
241 // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
242 // requester.ReturnResponseVal = TestResponse;
243 // requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
244 SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST",
245 m_userManager.
246 _config.
247 InventoryUrl +
248 "RootFolders/",
249 m_lastCreatedUser);
250 break; 252 break;
251 } 253 }
252 } 254 }
@@ -262,12 +264,11 @@ namespace OpenSim.Grid.UserServer
262 } 264 }
263 265
264 public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, 266 public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID,
265 ulong regionhandle, float positionX, float positionY, 267 ulong regionhandle, float positionX, float positionY,
266 float positionZ, string firstname, string lastname) 268 float positionZ, string firstname, string lastname)
267 { 269 {
268 270 m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX,
269 m_messagesService.TellMessageServersAboutUser( agentID, sessionID, RegionID, regionhandle, positionX, 271 positionY, positionZ, firstname, lastname);
270 positionY, positionZ, firstname, lastname);
271 } 272 }
272 } 273 }
273} 274} \ No newline at end of file