diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Grid/MessagingServer/Main.cs | 226 |
1 files changed, 226 insertions, 0 deletions
diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs new file mode 100644 index 0000000..a340ce8 --- /dev/null +++ b/OpenSim/Grid/MessagingServer/Main.cs | |||
@@ -0,0 +1,226 @@ | |||
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 OpenSim 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 | */ | ||
28 | |||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.IO; | ||
32 | using libsecondlife; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Framework.Console; | ||
36 | using OpenSim.Framework.Servers; | ||
37 | |||
38 | namespace OpenSim.Grid.MessagingServer | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// </summary> | ||
42 | public class OpenUser_Main : conscmd_callback | ||
43 | { | ||
44 | private UserConfig Cfg; | ||
45 | |||
46 | //public UserManager m_userManager; | ||
47 | //public UserLoginService m_loginService; | ||
48 | |||
49 | private LogBase m_console; | ||
50 | private LLUUID m_lastCreatedUser = LLUUID.Random(); | ||
51 | |||
52 | [STAThread] | ||
53 | public static void Main(string[] args) | ||
54 | { | ||
55 | Console.WriteLine("Launching UserServer..."); | ||
56 | |||
57 | OpenUser_Main userserver = new OpenUser_Main(); | ||
58 | |||
59 | userserver.Startup(); | ||
60 | userserver.Work(); | ||
61 | } | ||
62 | |||
63 | private OpenUser_Main() | ||
64 | { | ||
65 | if (!Directory.Exists(Util.logDir())) | ||
66 | { | ||
67 | Directory.CreateDirectory(Util.logDir()); | ||
68 | } | ||
69 | m_console = | ||
70 | new LogBase((Path.Combine(Util.logDir(), "opengrid-messagingserver-console.log")), "OpenUser", this, true); | ||
71 | MainLog.Instance = m_console; | ||
72 | } | ||
73 | |||
74 | private void Work() | ||
75 | { | ||
76 | m_console.Notice("Enter help for a list of commands\n"); | ||
77 | |||
78 | while (true) | ||
79 | { | ||
80 | m_console.MainLogPrompt(); | ||
81 | } | ||
82 | } | ||
83 | |||
84 | public void Startup() | ||
85 | { | ||
86 | Cfg = new UserConfig("MESSAGING SERVER", (Path.Combine(Util.configDir(), "MessagingServer_Config.xml"))); | ||
87 | |||
88 | MainLog.Instance.Verbose("REGION", "Establishing data connection"); | ||
89 | //m_userManager = new UserManager(); | ||
90 | //m_userManager._config = Cfg; | ||
91 | //m_userManager.AddPlugin(Cfg.DatabaseProvider); | ||
92 | |||
93 | //m_loginService = new UserLoginService( | ||
94 | //m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); | ||
95 | |||
96 | MainLog.Instance.Verbose("REGION", "Starting HTTP process"); | ||
97 | BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); | ||
98 | |||
99 | //httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); | ||
100 | |||
101 | //httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); | ||
102 | //httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID); | ||
103 | //httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar); | ||
104 | //httpServer.AddXmlRPCHandler("add_new_user_friend", m_userManager.XmlRpcResponseXmlRPCAddUserFriend); | ||
105 | //httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend); | ||
106 | //httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms); | ||
107 | //httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList); | ||
108 | |||
109 | |||
110 | //httpServer.AddStreamHandler( | ||
111 | //new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); | ||
112 | |||
113 | httpServer.Start(); | ||
114 | m_console.Status("SERVER", "Messageserver 0.4 - Startup complete"); | ||
115 | } | ||
116 | |||
117 | |||
118 | public void do_create(string what) | ||
119 | { | ||
120 | switch (what) | ||
121 | { | ||
122 | case "user": | ||
123 | string tempfirstname; | ||
124 | string templastname; | ||
125 | string tempMD5Passwd; | ||
126 | uint regX = 1000; | ||
127 | uint regY = 1000; | ||
128 | |||
129 | tempfirstname = m_console.CmdPrompt("First name"); | ||
130 | templastname = m_console.CmdPrompt("Last name"); | ||
131 | tempMD5Passwd = m_console.PasswdPrompt("Password"); | ||
132 | regX = Convert.ToUInt32(m_console.CmdPrompt("Start Region X")); | ||
133 | regY = Convert.ToUInt32(m_console.CmdPrompt("Start Region Y")); | ||
134 | |||
135 | tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); | ||
136 | |||
137 | LLUUID userID = new LLUUID(); | ||
138 | try | ||
139 | { | ||
140 | //userID = | ||
141 | //m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); | ||
142 | } catch (Exception ex) | ||
143 | { | ||
144 | m_console.Error("SERVER", "Error creating user: {0}", ex.ToString()); | ||
145 | } | ||
146 | |||
147 | try | ||
148 | { | ||
149 | //RestObjectPoster.BeginPostObject<Guid>(m_userManager._config.InventoryUrl + "CreateInventory/", | ||
150 | //userID.UUID); | ||
151 | } | ||
152 | catch (Exception ex) | ||
153 | { | ||
154 | m_console.Error("SERVER", "Error creating inventory for user: {0}", ex.ToString()); | ||
155 | } | ||
156 | m_lastCreatedUser = userID; | ||
157 | break; | ||
158 | } | ||
159 | } | ||
160 | |||
161 | public void RunCmd(string cmd, string[] cmdparams) | ||
162 | { | ||
163 | switch (cmd) | ||
164 | { | ||
165 | case "help": | ||
166 | m_console.Notice("create user - create a new user"); | ||
167 | m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); | ||
168 | break; | ||
169 | |||
170 | case "create": | ||
171 | do_create(cmdparams[0]); | ||
172 | break; | ||
173 | |||
174 | case "shutdown": | ||
175 | m_console.Close(); | ||
176 | Environment.Exit(0); | ||
177 | break; | ||
178 | |||
179 | case "test-inventory": | ||
180 | // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>(); | ||
181 | // requester.ReturnResponseVal = TestResponse; | ||
182 | // requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); | ||
183 | //List<InventoryFolderBase> folders = | ||
184 | //SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST", | ||
185 | //m_userManager. | ||
186 | //_config. | ||
187 | //InventoryUrl + | ||
188 | //"RootFolders/", | ||
189 | //m_lastCreatedUser); | ||
190 | break; | ||
191 | } | ||
192 | } | ||
193 | |||
194 | public void TestResponse(List<InventoryFolderBase> resp) | ||
195 | { | ||
196 | Console.WriteLine("response got"); | ||
197 | } | ||
198 | |||
199 | /*private void ConfigDB(IGenericConfig configData) | ||
200 | { | ||
201 | try | ||
202 | { | ||
203 | string attri = ""; | ||
204 | attri = configData.GetAttribute("DataBaseProvider"); | ||
205 | if (attri == "") | ||
206 | { | ||
207 | StorageDll = "OpenSim.Framework.Data.DB4o.dll"; | ||
208 | configData.SetAttribute("DataBaseProvider", "OpenSim.Framework.Data.DB4o.dll"); | ||
209 | } | ||
210 | else | ||
211 | { | ||
212 | StorageDll = attri; | ||
213 | } | ||
214 | configData.Commit(); | ||
215 | } | ||
216 | catch | ||
217 | { | ||
218 | |||
219 | } | ||
220 | }*/ | ||
221 | |||
222 | public void Show(string ShowWhat) | ||
223 | { | ||
224 | } | ||
225 | } | ||
226 | } \ No newline at end of file | ||