aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices-Source/OpenGridServices.UserServer/Main.cs
diff options
context:
space:
mode:
authorMW2007-05-24 12:16:50 +0000
committerMW2007-05-24 12:16:50 +0000
commit3376b82501000692d6dac24b051af738cdaf2737 (patch)
tree90ed0a5d4955236f011fa63fce9d555186b0d179 /OpenGridServices-Source/OpenGridServices.UserServer/Main.cs
parentAdded "terrain save grdmap <filename> <gradientmap>" function to console. Gra... (diff)
downloadopensim-SC_OLD-3376b82501000692d6dac24b051af738cdaf2737.zip
opensim-SC_OLD-3376b82501000692d6dac24b051af738cdaf2737.tar.gz
opensim-SC_OLD-3376b82501000692d6dac24b051af738cdaf2737.tar.bz2
opensim-SC_OLD-3376b82501000692d6dac24b051af738cdaf2737.tar.xz
Some more code refactoring, plus a restructuring of the directories so that the Grid servers can be a separate solution to the region server.
Diffstat (limited to 'OpenGridServices-Source/OpenGridServices.UserServer/Main.cs')
-rw-r--r--OpenGridServices-Source/OpenGridServices.UserServer/Main.cs197
1 files changed, 197 insertions, 0 deletions
diff --git a/OpenGridServices-Source/OpenGridServices.UserServer/Main.cs b/OpenGridServices-Source/OpenGridServices.UserServer/Main.cs
new file mode 100644
index 0000000..0eb314b
--- /dev/null
+++ b/OpenGridServices-Source/OpenGridServices.UserServer/Main.cs
@@ -0,0 +1,197 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Collections;
32using System.Collections.Generic;
33using System.Reflection;
34using System.IO;
35using System.Text;
36using libsecondlife;
37using OpenSim.Framework.User;
38using OpenSim.Framework.Sims;
39using OpenSim.Framework.Inventory;
40using OpenSim.Framework.Interfaces;
41using OpenSim.Framework.Console;
42using OpenSim.Servers;
43
44namespace OpenGridServices.UserServer
45{
46 /// <summary>
47 /// </summary>
48 public class OpenUser_Main : BaseServer, conscmd_callback
49 {
50 private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll";
51 private string StorageDll = "OpenGrid.Framework.Data.MySQL.dll";
52 private UserConfig Cfg;
53
54 public UserManager m_userManager; // Replaces below.
55
56 //private UserProfileManager m_userProfileManager; // Depreciated
57
58 public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
59
60 ConsoleBase m_console;
61
62 [STAThread]
63 public static void Main(string[] args)
64 {
65 Console.WriteLine("Starting...\n");
66
67 OpenUser_Main userserver = new OpenUser_Main();
68
69 userserver.Startup();
70 userserver.Work();
71 }
72
73 private OpenUser_Main()
74 {
75 m_console = new ConsoleBase("opengrid-userserver-console.log", "OpenUser", this , false);
76 MainConsole.Instance = m_console;
77 }
78
79 private void Work()
80 {
81 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"\nEnter help for a list of commands\n");
82
83 while (true)
84 {
85 m_console.MainConsolePrompt();
86 }
87 }
88
89 public void Startup()
90 {
91 MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Loading configuration");
92 Cfg = this.LoadConfigDll(this.ConfigDll);
93 Cfg.InitConfig();
94
95 MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Establishing data connection");
96 m_userManager = new UserManager();
97 m_userManager._config = Cfg;
98 m_userManager.AddPlugin(StorageDll);
99
100 MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Starting HTTP process");
101 BaseHttpServer httpServer = new BaseHttpServer(8002);
102
103 httpServer.AddXmlRPCHandler("login_to_simulator", m_userManager.XmlRpcLoginMethod);
104 httpServer.AddRestHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod);
105
106 httpServer.Start();
107 }
108
109
110 public void do_create(string what)
111 {
112 switch (what)
113 {
114 case "user":
115 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"Commandline user creation is currently disabled.");
116 break;
117 /*
118 string tempfirstname;
119 string templastname;
120 string tempMD5Passwd;
121
122 tempfirstname = m_console.CmdPrompt("First name");
123 templastname = m_console.CmdPrompt("Last name");
124 tempMD5Passwd = m_console.PasswdPrompt("Password");
125
126 System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
127 byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd);
128 bs = x.ComputeHash(bs);
129 System.Text.StringBuilder s = new System.Text.StringBuilder();
130 foreach (byte b in bs)
131 {
132 s.Append(b.ToString("x2").ToLower());
133 }
134 tempMD5Passwd = s.ToString();
135
136 UserProfile newuser = m_userProfileManager.CreateNewProfile(tempfirstname, templastname, tempMD5Passwd);
137 newuser.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f);
138 newuser.homepos = new LLVector3(128f, 128f, 150f);
139 m_userProfileManager.SaveUserProfiles();
140 break;
141 */
142 }
143 }
144
145 public void RunCmd(string cmd, string[] cmdparams)
146 {
147 switch (cmd)
148 {
149 case "help":
150 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"create user - create a new user");
151 m_console.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH,"shutdown - shutdown the grid (USE CAUTION!)");
152 break;
153
154 case "create":
155 do_create(cmdparams[0]);
156 break;
157
158 case "shutdown":
159 m_console.Close();
160 Environment.Exit(0);
161 break;
162 }
163 }
164
165 private UserConfig LoadConfigDll(string dllName)
166 {
167 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
168 UserConfig config = null;
169
170 foreach (Type pluginType in pluginAssembly.GetTypes())
171 {
172 if (pluginType.IsPublic)
173 {
174 if (!pluginType.IsAbstract)
175 {
176 Type typeInterface = pluginType.GetInterface("IUserConfig", true);
177
178 if (typeInterface != null)
179 {
180 IUserConfig plug = (IUserConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
181 config = plug.GetConfigObject();
182 break;
183 }
184
185 typeInterface = null;
186 }
187 }
188 }
189 pluginAssembly = null;
190 return config;
191 }
192
193 public void Show(string ShowWhat)
194 {
195 }
196 }
197}