diff options
Diffstat (limited to 'OpenSim/Grid/UserServer')
-rw-r--r-- | OpenSim/Grid/UserServer/Main.cs | 18 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer/MessageServersConnector.cs | 157 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer/UserLoginService.cs | 9 |
3 files changed, 183 insertions, 1 deletions
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 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Text; | ||
5 | using System.Threading; | ||
6 | using libsecondlife; | ||
7 | using Nwc.XmlRpc; | ||
8 | using OpenSim.Framework; | ||
9 | using OpenSim.Framework.Communications.Cache; | ||
10 | using OpenSim.Framework.Console; | ||
11 | using OpenSim.Framework.Servers; | ||
12 | |||
13 | namespace 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 | ||
44 | namespace OpenSim.Grid.UserServer | 44 | namespace 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) |