Main.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. using System;
  28. using System.IO;
  29. using System.Reflection;
  30. using libsecondlife;
  31. using log4net;
  32. using log4net.Config;
  33. using OpenSim.Framework;
  34. using OpenSim.Framework.Console;
  35. using OpenSim.Framework.Servers;
  36. namespace OpenSim.Grid.MessagingServer
  37. {
  38. /// <summary>
  39. /// </summary>
  40. public class OpenMessage_Main : BaseOpenSimServer, conscmd_callback
  41. {
  42. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  43. private MessageServerConfig Cfg;
  44. private MessageService msgsvc;
  45. private LLUUID m_lastCreatedUser = LLUUID.Random();
  46. [STAThread]
  47. public static void Main(string[] args)
  48. {
  49. XmlConfigurator.Configure();
  50. m_log.Info("Launching MessagingServer...");
  51. OpenMessage_Main messageserver = new OpenMessage_Main();
  52. messageserver.Startup();
  53. messageserver.Work();
  54. }
  55. private OpenMessage_Main()
  56. {
  57. m_console = new ConsoleBase("Messaging", this);
  58. MainConsole.Instance = m_console;
  59. }
  60. private void Work()
  61. {
  62. m_console.Notice("Enter help for a list of commands\n");
  63. while (true)
  64. {
  65. m_console.Prompt();
  66. }
  67. }
  68. public void Startup()
  69. {
  70. Cfg = new MessageServerConfig("MESSAGING SERVER", (Path.Combine(Util.configDir(), "MessagingServer_Config.xml")));
  71. m_log.Info("[REGION]: Starting HTTP process");
  72. m_httpServer = new BaseHttpServer(Cfg.HttpPort);
  73. msgsvc = new MessageService(Cfg);
  74. if (msgsvc.registerWithUserServer())
  75. {
  76. m_httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn);
  77. m_httpServer.AddXmlRPCHandler("logout_of_simulator", msgsvc.UserLoggedOff);
  78. //httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName);
  79. //httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID);
  80. //httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar);
  81. //httpServer.AddXmlRPCHandler("add_new_user_friend", m_userManager.XmlRpcResponseXmlRPCAddUserFriend);
  82. //httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend);
  83. //httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms);
  84. //httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList);
  85. //httpServer.AddStreamHandler(
  86. //new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
  87. m_httpServer.Start();
  88. m_log.Info("[SERVER]: Messageserver 0.5 - Startup complete");
  89. }
  90. else
  91. {
  92. m_log.Error("[STARTUP]: Unable to connect to User Server");
  93. }
  94. }
  95. public void do_create(string what)
  96. {
  97. switch (what)
  98. {
  99. case "user":
  100. try
  101. {
  102. //userID =
  103. //m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
  104. } catch (Exception ex)
  105. {
  106. m_console.Error("[SERVER]: Error creating user: {0}", ex.ToString());
  107. }
  108. try
  109. {
  110. //RestObjectPoster.BeginPostObject<Guid>(m_userManager._config.InventoryUrl + "CreateInventory/",
  111. //userID.UUID);
  112. }
  113. catch (Exception ex)
  114. {
  115. m_console.Error("[SERVER]: Error creating inventory for user: {0}", ex.ToString());
  116. }
  117. // m_lastCreatedUser = userID;
  118. break;
  119. }
  120. }
  121. public override void Shutdown()
  122. {
  123. msgsvc.deregisterWithUserServer();
  124. base.Shutdown();
  125. }
  126. }
  127. }