aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid
diff options
context:
space:
mode:
authorTeravus Ovares2008-01-06 18:18:19 +0000
committerTeravus Ovares2008-01-06 18:18:19 +0000
commitb8efd5f2949dd247590c1e40509e71031faf3413 (patch)
tree02307ef3edef08bf1a393d89cd772ad8d0ee7ae5 /OpenSim/Grid
parentSet svn:eol-style. (diff)
downloadopensim-SC_OLD-b8efd5f2949dd247590c1e40509e71031faf3413.zip
opensim-SC_OLD-b8efd5f2949dd247590c1e40509e71031faf3413.tar.gz
opensim-SC_OLD-b8efd5f2949dd247590c1e40509e71031faf3413.tar.bz2
opensim-SC_OLD-b8efd5f2949dd247590c1e40509e71031faf3413.tar.xz
* Added some userserver glue for communications with the message server
* Added some code for the message server, fixed a few references and starting to flesh it out.
Diffstat (limited to 'OpenSim/Grid')
-rw-r--r--OpenSim/Grid/MessagingServer/Main.cs88
-rw-r--r--OpenSim/Grid/UserServer/Main.cs18
-rw-r--r--OpenSim/Grid/UserServer/MessageServersConnector.cs157
-rw-r--r--OpenSim/Grid/UserServer/UserLoginService.cs9
4 files changed, 197 insertions, 75 deletions
diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs
index a69cef3..8f64113 100644
--- a/OpenSim/Grid/MessagingServer/Main.cs
+++ b/OpenSim/Grid/MessagingServer/Main.cs
@@ -39,9 +39,9 @@ namespace OpenSim.Grid.MessagingServer
39{ 39{
40 /// <summary> 40 /// <summary>
41 /// </summary> 41 /// </summary>
42 public class OpenUser_Main : conscmd_callback 42 public class OpenMessage_Main : conscmd_callback
43 { 43 {
44 private UserConfig Cfg; 44 private MessageServerConfig Cfg;
45 45
46 //public UserManager m_userManager; 46 //public UserManager m_userManager;
47 //public UserLoginService m_loginService; 47 //public UserLoginService m_loginService;
@@ -52,22 +52,22 @@ namespace OpenSim.Grid.MessagingServer
52 [STAThread] 52 [STAThread]
53 public static void Main(string[] args) 53 public static void Main(string[] args)
54 { 54 {
55 Console.WriteLine("Launching UserServer..."); 55 Console.WriteLine("Launching MessagingServer...");
56 56
57 OpenUser_Main userserver = new OpenUser_Main(); 57 OpenMessage_Main messageserver = new OpenMessage_Main();
58 58
59 userserver.Startup(); 59 messageserver.Startup();
60 userserver.Work(); 60 messageserver.Work();
61 } 61 }
62 62
63 private OpenUser_Main() 63 private OpenMessage_Main()
64 { 64 {
65 if (!Directory.Exists(Util.logDir())) 65 if (!Directory.Exists(Util.logDir()))
66 { 66 {
67 Directory.CreateDirectory(Util.logDir()); 67 Directory.CreateDirectory(Util.logDir());
68 } 68 }
69 m_console = 69 m_console =
70 new LogBase((Path.Combine(Util.logDir(), "opengrid-messagingserver-console.log")), "OpenUser", this, true); 70 new LogBase((Path.Combine(Util.logDir(), "opengrid-messagingserver-console.log")), "OpenMessage", this, true);
71 MainLog.Instance = m_console; 71 MainLog.Instance = m_console;
72 } 72 }
73 73
@@ -83,9 +83,9 @@ namespace OpenSim.Grid.MessagingServer
83 83
84 public void Startup() 84 public void Startup()
85 { 85 {
86 Cfg = new UserConfig("MESSAGING SERVER", (Path.Combine(Util.configDir(), "MessagingServer_Config.xml"))); 86 Cfg = new MessageServerConfig("MESSAGING SERVER", (Path.Combine(Util.configDir(), "MessagingServer_Config.xml")));
87 87
88 MainLog.Instance.Verbose("REGION", "Establishing data connection"); 88 //MainLog.Instance.Verbose("REGION", "Establishing data connection");
89 //m_userManager = new UserManager(); 89 //m_userManager = new UserManager();
90 //m_userManager._config = Cfg; 90 //m_userManager._config = Cfg;
91 //m_userManager.AddPlugin(Cfg.DatabaseProvider); 91 //m_userManager.AddPlugin(Cfg.DatabaseProvider);
@@ -120,21 +120,7 @@ namespace OpenSim.Grid.MessagingServer
120 switch (what) 120 switch (what)
121 { 121 {
122 case "user": 122 case "user":
123 string tempfirstname; 123
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 124 try
139 { 125 {
140 //userID = 126 //userID =
@@ -153,7 +139,7 @@ namespace OpenSim.Grid.MessagingServer
153 { 139 {
154 m_console.Error("SERVER", "Error creating inventory for user: {0}", ex.ToString()); 140 m_console.Error("SERVER", "Error creating inventory for user: {0}", ex.ToString());
155 } 141 }
156 m_lastCreatedUser = userID; 142 // m_lastCreatedUser = userID;
157 break; 143 break;
158 } 144 }
159 } 145 }
@@ -163,64 +149,18 @@ namespace OpenSim.Grid.MessagingServer
163 switch (cmd) 149 switch (cmd)
164 { 150 {
165 case "help": 151 case "help":
166 m_console.Notice("create user - create a new user"); 152 m_console.Notice("shutdown - shutdown the message server (USE CAUTION!)");
167 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
168 break;
169
170 case "create":
171 do_create(cmdparams[0]);
172 break; 153 break;
173 154
174 case "shutdown": 155 case "shutdown":
175 m_console.Close(); 156 m_console.Close();
176 Environment.Exit(0); 157 Environment.Exit(0);
177 break; 158 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 } 159 }
192 } 160 }
193 161
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) 162 public void Show(string ShowWhat)
223 { 163 {
224 } 164 }
225 } 165 }
226} \ No newline at end of file 166}
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 5264870..8e6817d 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -42,9 +42,11 @@ namespace OpenSim.Grid.UserServer
42 public class OpenUser_Main : conscmd_callback 42 public class OpenUser_Main : conscmd_callback
43 { 43 {
44 private UserConfig Cfg; 44 private UserConfig Cfg;
45
45 46
46 public UserManager m_userManager; 47 public UserManager m_userManager;
47 public UserLoginService m_loginService; 48 public UserLoginService m_loginService;
49 public MessageServersConnector m_messagesService;
48 50
49 private LogBase m_console; 51 private LogBase m_console;
50 private LLUUID m_lastCreatedUser = LLUUID.Random(); 52 private LLUUID m_lastCreatedUser = LLUUID.Random();
@@ -93,6 +95,10 @@ namespace OpenSim.Grid.UserServer
93 m_loginService = new UserLoginService( 95 m_loginService = new UserLoginService(
94 m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); 96 m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg);
95 97
98 m_messagesService = new MessageServersConnector(MainLog.Instance);
99
100 m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
101
96 MainLog.Instance.Verbose("REGION", "Starting HTTP process"); 102 MainLog.Instance.Verbose("REGION", "Starting HTTP process");
97 BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); 103 BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort);
98 104
@@ -106,7 +112,12 @@ namespace OpenSim.Grid.UserServer
106 httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend); 112 httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend);
107 httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms); 113 httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms);
108 httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList); 114 httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList);
109 115
116 // Message Server ---> User Server
117 httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer);
118 httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion);
119 httpServer.AddXmlRPCHandler("deregister_messageserver", m_messagesService.XmlRPCDeRegisterMessageServer);
120
110 121
111 httpServer.AddStreamHandler( 122 httpServer.AddStreamHandler(
112 new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); 123 new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
@@ -173,6 +184,7 @@ namespace OpenSim.Grid.UserServer
173 break; 184 break;
174 185
175 case "shutdown": 186 case "shutdown":
187 m_loginService.OnUserLoggedInAtLocation -= NotifyMessageServersUserLoggedInToLocation;
176 m_console.Close(); 188 m_console.Close();
177 Environment.Exit(0); 189 Environment.Exit(0);
178 break; 190 break;
@@ -196,6 +208,10 @@ namespace OpenSim.Grid.UserServer
196 { 208 {
197 Console.WriteLine("response got"); 209 Console.WriteLine("response got");
198 } 210 }
211 public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position)
212 {
213 m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, Position);
214 }
199 215
200 /*private void ConfigDB(IGenericConfig configData) 216 /*private void ConfigDB(IGenericConfig configData)
201 { 217 {
diff --git a/OpenSim/Grid/UserServer/MessageServersConnector.cs b/OpenSim/Grid/UserServer/MessageServersConnector.cs
new file mode 100644
index 0000000..deec739
--- /dev/null
+++ b/OpenSim/Grid/UserServer/MessageServersConnector.cs
@@ -0,0 +1,157 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Text;
5using System.Threading;
6using libsecondlife;
7using Nwc.XmlRpc;
8using OpenSim.Framework;
9using OpenSim.Framework.Communications.Cache;
10using OpenSim.Framework.Console;
11using OpenSim.Framework.Servers;
12
13namespace OpenSim.Grid.UserServer
14{
15
16 public class MessageServersConnector
17 {
18 private LogBase m_log;
19 public Dictionary<string, MessageServerInfo> MessageServers;
20
21 public MessageServersConnector(LogBase log)
22 {
23 m_log=log;
24 MessageServers = new Dictionary<string, MessageServerInfo>();
25 }
26
27 public void RegisterMessageServer(string URI, MessageServerInfo serverData)
28 {
29 MessageServers.Add(URI, serverData);
30 }
31
32 public void DeRegisterMessageServer(string URI)
33 {
34 MessageServers.Remove(URI);
35 }
36
37 public void AddResponsibleRegion(string URI, ulong regionhandle)
38 {
39 if (!MessageServers.ContainsKey(URI))
40 {
41 m_log.Warn("MSGSERVER", "Got addResponsibleRegion Request for a MessageServer that isn't registered");
42 }
43 else
44 {
45 MessageServerInfo msginfo = MessageServers["URI"];
46 msginfo.responsibleForRegions.Add(regionhandle);
47 MessageServers["URI"] = msginfo;
48 }
49 }
50 public void RemoveResponsibleRegion(string URI, ulong regionhandle)
51 {
52 if (!MessageServers.ContainsKey(URI))
53 {
54 m_log.Warn("MSGSERVER", "Got RemoveResponsibleRegion Request for a MessageServer that isn't registered");
55 }
56 else
57 {
58 MessageServerInfo msginfo = MessageServers["URI"];
59 if (msginfo.responsibleForRegions.Contains(regionhandle))
60 {
61 msginfo.responsibleForRegions.Remove(regionhandle);
62 MessageServers["URI"] = msginfo;
63 }
64 }
65
66 }
67 public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request)
68 {
69 XmlRpcResponse response = new XmlRpcResponse();
70 Hashtable requestData = (Hashtable)request.Params[0];
71 Hashtable responseData = new Hashtable();
72
73 if (requestData.Contains("uri"))
74 {
75 string URI = (string)requestData["URI"];
76 string sendkey=(string)requestData["sendkey"];
77 string recvkey=(string)requestData["recvkey"];
78 MessageServerInfo m = new MessageServerInfo();
79 m.URI = URI;
80 m.sendkey = sendkey;
81 m.recvkey = recvkey;
82 RegisterMessageServer(URI, m);
83 responseData["responsestring"] = "TRUE";
84 response.Value = responseData;
85 }
86 return response;
87 }
88 public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request)
89 {
90 XmlRpcResponse response = new XmlRpcResponse();
91 Hashtable requestData = (Hashtable)request.Params[0];
92 Hashtable responseData = new Hashtable();
93
94 if (requestData.Contains("uri"))
95 {
96 string URI = (string)requestData["URI"];
97
98 DeRegisterMessageServer(URI);
99 responseData["responsestring"] = "TRUE";
100 response.Value = responseData;
101 }
102 return response;
103 }
104 public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request)
105 {
106 XmlRpcResponse response = new XmlRpcResponse();
107 Hashtable requestData = (Hashtable)request.Params[0];
108 Hashtable responseData = new Hashtable();
109
110 if (requestData.Contains("fromuri"))
111 {
112 string sURI = (string)requestData["fromuri"];
113 string sagentID = (string)requestData["agentid"];
114 string ssessionID = (string)requestData["sessionid"];
115 string scurrentRegionID = (string)requestData["regionid"];
116 string sregionhandle = (string)requestData["regionhandle"];
117 string scurrentpos = (string)requestData["currentpos"];
118 //LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos);
119 // TODO: Okay now raise event so the user server can pass this data to the Usermanager
120
121 responseData["responsestring"] = "TRUE";
122 response.Value = responseData;
123 }
124 return response;
125 }
126
127 public void TellMessageServersAboutUser(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position)
128 {
129 // Loop over registered Message Servers ( AND THERE WILL BE MORE THEN ONE :D )
130 foreach (MessageServerInfo serv in MessageServers.Values)
131 {
132 NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID, regionhandle, Position);
133 }
134 }
135
136 private void NotifyMessageServerAboutUser(MessageServerInfo serv, LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position)
137 {
138 Hashtable reqparams = new Hashtable();
139 reqparams["sendkey"] = serv.sendkey;
140 reqparams["agentid"] = agentID.ToString();
141 reqparams["sessionid"] = sessionID.ToString();
142 reqparams["regionid"] = RegionID.ToString();
143 reqparams["regionhandle"] = regionhandle.ToString();
144 reqparams["position"] = Position.ToString();
145
146 ArrayList SendParams = new ArrayList();
147 SendParams.Add(reqparams);
148
149 XmlRpcRequest GridReq = new XmlRpcRequest("user_login", SendParams);
150 XmlRpcResponse GridResp = GridReq.Send(serv.URI, 6000);
151 m_log.Verbose("LOGIN","Notified : " + serv.URI + " about user login");
152
153 }
154
155
156 }
157}
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs
index 1a3bf2e..98d19f7 100644
--- a/OpenSim/Grid/UserServer/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer/UserLoginService.cs
@@ -43,8 +43,13 @@ using InventoryFolder=OpenSim.Framework.InventoryFolder;
43 43
44namespace OpenSim.Grid.UserServer 44namespace OpenSim.Grid.UserServer
45{ 45{
46 public delegate void UserLoggedInAtLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position);
47
48
46 public class UserLoginService : LoginService 49 public class UserLoginService : LoginService
47 { 50 {
51 public event UserLoggedInAtLocation OnUserLoggedInAtLocation;
52
48 public UserConfig m_config; 53 public UserConfig m_config;
49 54
50 public UserLoginService( 55 public UserLoginService(
@@ -198,6 +203,10 @@ namespace OpenSim.Grid.UserServer
198 // Send 203 // Send
199 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); 204 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
200 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); 205 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
206 if (OnUserLoggedInAtLocation != null)
207 {
208 OnUserLoggedInAtLocation(theUser.UUID, theUser.currentAgent.sessionID, theUser.currentAgent.currentRegion, theUser.currentAgent.currentHandle, theUser.currentAgent.currentPos);
209 }
201 } 210 }
202 211
203 catch (Exception e) 212 catch (Exception e)