Main.cs 6.4 KB

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