From b831a91852b34473f993f9a3e88ddd4e0c8455ca Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 25 Feb 2008 06:33:14 +0000 Subject: * Message Server Linkages (still not ready for use so don't start it yet) --- OpenSim/Framework/MessageServerConfig.cs | 6 ++ OpenSim/Grid/MessagingServer/Main.cs | 37 +++++--- OpenSim/Grid/MessagingServer/MessageService.cs | 104 ++++++++++++++++++++- OpenSim/Grid/UserServer/Main.cs | 1 + OpenSim/Grid/UserServer/MessageServersConnector.cs | 10 +- OpenSim/Grid/UserServer/UserLoginService.cs | 9 +- 6 files changed, 152 insertions(+), 15 deletions(-) diff --git a/OpenSim/Framework/MessageServerConfig.cs b/OpenSim/Framework/MessageServerConfig.cs index 5ee7a46..69b0651 100644 --- a/OpenSim/Framework/MessageServerConfig.cs +++ b/OpenSim/Framework/MessageServerConfig.cs @@ -45,6 +45,7 @@ namespace OpenSim.Framework public string GridServerURL = String.Empty; public string GridSendKey = String.Empty; public string GridRecvKey = String.Empty; + public string MessageServerIP = String.Empty; public string DatabaseProvider = String.Empty; public string GridCommsProvider = String.Empty; @@ -92,6 +93,8 @@ namespace OpenSim.Framework "Http Listener port", DefaultHttpPort.ToString(), false); configMember.addConfigurationOption("http_ssl", ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN, "Use SSL? true/false", DefaultHttpSSL.ToString(), false); + configMember.addConfigurationOption("published_ip", ConfigurationOption.ConfigurationTypes.TYPE_STRING, + "My Published IP Address", "127.0.0.1", false); } @@ -130,6 +133,9 @@ namespace OpenSim.Framework case "region_comms_provider": GridCommsProvider = (string)configuration_result; break; + case "published_ip": + MessageServerIP = (string)configuration_result; + break; } return true; diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs index 6ac70f0..5a383ef 100644 --- a/OpenSim/Grid/MessagingServer/Main.cs +++ b/OpenSim/Grid/MessagingServer/Main.cs @@ -44,6 +44,7 @@ namespace OpenSim.Grid.MessagingServer private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private MessageServerConfig Cfg; + private MessageService msgsvc; //public UserManager m_userManager; //public UserLoginService m_loginService; @@ -57,6 +58,8 @@ namespace OpenSim.Grid.MessagingServer m_log.Info("Launching MessagingServer..."); + + OpenMessage_Main messageserver = new OpenMessage_Main(); messageserver.Startup(); @@ -85,23 +88,32 @@ namespace OpenSim.Grid.MessagingServer m_log.Info("[REGION]: Starting HTTP process"); BaseHttpServer httpServer = new BaseHttpServer(Cfg.HttpPort); + + msgsvc = new MessageService(Cfg); - //httpServer.AddXmlRPCHandler("login_to_simulator", m_loginService.XmlRpcLoginMethod); + if (msgsvc.registerWithUserServer()) + { + httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn); - //httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); - //httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID); - //httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar); - //httpServer.AddXmlRPCHandler("add_new_user_friend", m_userManager.XmlRpcResponseXmlRPCAddUserFriend); - //httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend); - //httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms); - //httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList); - + //httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); + //httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID); + //httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar); + //httpServer.AddXmlRPCHandler("add_new_user_friend", m_userManager.XmlRpcResponseXmlRPCAddUserFriend); + //httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend); + //httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms); + //httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList); - //httpServer.AddStreamHandler( + + //httpServer.AddStreamHandler( //new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); - httpServer.Start(); - m_log.Info("[SERVER]: Messageserver 0.5 - Startup complete"); + httpServer.Start(); + m_log.Info("[SERVER]: Messageserver 0.5 - Startup complete"); + } + else + { + m_log.Error("[STARTUP]: Unable to connect to User Server"); + } } public void do_create(string what) @@ -144,6 +156,7 @@ namespace OpenSim.Grid.MessagingServer break; case "shutdown": + msgsvc.deregisterWithUserServer(); m_console.Close(); Environment.Exit(0); break; diff --git a/OpenSim/Grid/MessagingServer/MessageService.cs b/OpenSim/Grid/MessagingServer/MessageService.cs index 059a6b0..42277e2 100644 --- a/OpenSim/Grid/MessagingServer/MessageService.cs +++ b/OpenSim/Grid/MessagingServer/MessageService.cs @@ -333,7 +333,7 @@ namespace OpenSim.Grid.MessagingServer /// public XmlRpcResponse UserLoggedOn(XmlRpcRequest request) { - + m_log.Info("[LOGON]: User logged on, building indexes for user"); Hashtable requestData = (Hashtable)request.Params[0]; AgentCircuitData agentData = new AgentCircuitData(); agentData.SessionID = new LLUUID((string)requestData["session_id"]); @@ -472,6 +472,108 @@ namespace OpenSim.Grid.MessagingServer return regionProfile; } + public bool registerWithUserServer () + { + + Hashtable UserParams = new Hashtable(); + // Login / Authentication + + if (m_cfg.HttpSSL) + { + UserParams["uri"] = "https://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; + } + else + { + UserParams["uri"] = "http://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; + } + + UserParams["recvkey"] = m_cfg.UserRecvKey; + UserParams["sendkey"] = m_cfg.UserRecvKey; + + + + + // Package into an XMLRPC Request + ArrayList SendParams = new ArrayList(); + SendParams.Add(UserParams); + + // Send Request + XmlRpcRequest UserReq; + XmlRpcResponse UserResp; + try + { + UserReq = new XmlRpcRequest("register_messageserver", SendParams); + UserResp = UserReq.Send(m_cfg.UserServerURL, 16000); + } catch (Exception ex) + { + m_log.Error("Unable to connect to grid. Grid server not running?"); + throw(ex); + } + Hashtable GridRespData = (Hashtable)UserResp.Value; + Hashtable griddatahash = GridRespData; + + // Process Response + if (GridRespData.ContainsKey("responsestring")) + { + return true; + } + else + { + return false; + } + + + } + public bool deregisterWithUserServer() + { + + Hashtable UserParams = new Hashtable(); + // Login / Authentication + + if (m_cfg.HttpSSL) + { + UserParams["uri"] = "https://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; + } + else + { + UserParams["uri"] = "http://" + m_cfg.MessageServerIP + ":" + m_cfg.HttpPort; + } + + UserParams["recvkey"] = m_cfg.UserRecvKey; + UserParams["sendkey"] = m_cfg.UserRecvKey; + + // Package into an XMLRPC Request + ArrayList SendParams = new ArrayList(); + SendParams.Add(UserParams); + + // Send Request + XmlRpcRequest UserReq; + XmlRpcResponse UserResp; + try + { + UserReq = new XmlRpcRequest("deregister_messageserver", SendParams); + UserResp = UserReq.Send(m_cfg.UserServerURL, 16000); + } + catch (Exception ex) + { + m_log.Error("Unable to connect to grid. Grid server not running?"); + throw (ex); + } + Hashtable UserRespData = (Hashtable)UserResp.Value; + Hashtable userdatahash = UserRespData; + + // Process Response + if (UserRespData.ContainsKey("responsestring")) + { + return true; + } + else + { + return false; + } + + + } #endregion } diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 3500665..3a3b8b6 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -227,6 +227,7 @@ namespace OpenSim.Grid.UserServer public void NotifyMessageServersUserLoggedInToLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position) { + m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, Position); } diff --git a/OpenSim/Grid/UserServer/MessageServersConnector.cs b/OpenSim/Grid/UserServer/MessageServersConnector.cs index 251644b..6535247 100644 --- a/OpenSim/Grid/UserServer/MessageServersConnector.cs +++ b/OpenSim/Grid/UserServer/MessageServersConnector.cs @@ -119,7 +119,7 @@ namespace OpenSim.Grid.UserServer if (requestData.Contains("uri")) { - string URI = (string)requestData["URI"]; + string URI = (string)requestData["uri"]; DeRegisterMessageServer(URI); responseData["responsestring"] = "TRUE"; @@ -153,6 +153,14 @@ namespace OpenSim.Grid.UserServer public void TellMessageServersAboutUser(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, ulong regionhandle, LLVector3 Position) { // Loop over registered Message Servers ( AND THERE WILL BE MORE THEN ONE :D ) + if (MessageServers.Count > 0) + { + m_log.Info("[MSGCONNECTOR]: Sending login notice to registered message servers"); + } + else + { + m_log.Info("[MSGCONNECTOR]: No Message Servers registered, ignoring"); + } foreach (MessageServerInfo serv in MessageServers.Values) { NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID, regionhandle, Position); diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index 80899e8..a82b978 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -144,7 +144,13 @@ namespace OpenSim.Grid.UserServer m_log.ErrorFormat( "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}", SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); - } + } + handler001 = OnUserLoggedInAtLocation; + if (handler001 != null) + { + m_log.Info("[LOGIN]: Letting other objects know about login"); + handler001(theUser.UUID, theUser.currentAgent.sessionID, theUser.currentAgent.currentRegion, theUser.currentAgent.currentHandle, theUser.currentAgent.currentPos); + } } catch (Exception) { @@ -219,6 +225,7 @@ namespace OpenSim.Grid.UserServer handler001 = OnUserLoggedInAtLocation; if (handler001 != null) { + m_log.Info("[LOGIN]: Letting other objects know about login"); handler001(theUser.UUID, theUser.currentAgent.sessionID, theUser.currentAgent.currentRegion, theUser.currentAgent.currentHandle, theUser.currentAgent.currentPos); } } -- cgit v1.1