RemoteBootstrapProxy.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using SuperSocket.SocketBase;
  6. using SuperSocket.SocketBase.Config;
  7. using SuperSocket.SocketBase.Logging;
  8. namespace SuperSocket.SocketEngine
  9. {
  10. class RemoteBootstrapProxy : MarshalByRefObject, IBootstrap
  11. {
  12. class ServerProxy : MarshalByRefObject, IWorkItem
  13. {
  14. private IWorkItem m_Server;
  15. public ServerProxy(IWorkItem server)
  16. {
  17. m_Server = server;
  18. }
  19. public bool Setup(IBootstrap bootstrap, IServerConfig config, SocketBase.Provider.ProviderFactoryInfo[] factories)
  20. {
  21. throw new NotSupportedException();
  22. }
  23. public ServerState State
  24. {
  25. get { return m_Server.State; }
  26. }
  27. public string Name
  28. {
  29. get { return m_Server.Name; }
  30. }
  31. public void ReportPotentialConfigChange(IServerConfig config)
  32. {
  33. m_Server.ReportPotentialConfigChange(config);
  34. }
  35. public bool Start()
  36. {
  37. return m_Server.Start();
  38. }
  39. public void Stop()
  40. {
  41. m_Server.Stop();
  42. }
  43. public int SessionCount
  44. {
  45. get { throw new NotSupportedException(); }
  46. }
  47. public SocketBase.Metadata.StatusInfoAttribute[] GetServerStatusMetadata()
  48. {
  49. throw new NotSupportedException();
  50. }
  51. public StatusInfoCollection CollectServerStatus(StatusInfoCollection bootstrapStatus)
  52. {
  53. throw new NotSupportedException();
  54. }
  55. public void TransferSystemMessage(string messageType, object messageData)
  56. {
  57. throw new NotSupportedException();
  58. }
  59. public IServerConfig Config
  60. {
  61. get
  62. {
  63. throw new NotSupportedException();
  64. }
  65. }
  66. }
  67. private IBootstrap m_Bootstrap;
  68. private List<IWorkItem> m_Servers = new List<IWorkItem>();
  69. public RemoteBootstrapProxy()
  70. {
  71. m_Bootstrap = (IBootstrap)AppDomain.CurrentDomain.GetData("Bootstrap");
  72. foreach (var s in m_Bootstrap.AppServers)
  73. {
  74. if (s is MarshalByRefObject)
  75. m_Servers.Add(s);
  76. else
  77. m_Servers.Add(new ServerProxy(s));
  78. }
  79. }
  80. public IEnumerable<IWorkItem> AppServers
  81. {
  82. get { return m_Servers; }
  83. }
  84. public IRootConfig Config
  85. {
  86. get { return m_Bootstrap.Config; }
  87. }
  88. public bool Initialize()
  89. {
  90. throw new NotSupportedException();
  91. }
  92. public bool Initialize(IDictionary<string, System.Net.IPEndPoint> listenEndPointReplacement)
  93. {
  94. throw new NotSupportedException();
  95. }
  96. public bool Initialize(Func<IServerConfig, IServerConfig> serverConfigResolver)
  97. {
  98. throw new NotSupportedException();
  99. }
  100. public bool Initialize(ILogFactory logFactory)
  101. {
  102. throw new NotSupportedException();
  103. }
  104. public bool Initialize(Func<IServerConfig, IServerConfig> serverConfigResolver, ILogFactory logFactory)
  105. {
  106. throw new NotSupportedException();
  107. }
  108. public StartResult Start()
  109. {
  110. throw new NotSupportedException();
  111. }
  112. public void Stop()
  113. {
  114. throw new NotSupportedException();
  115. }
  116. public string StartupConfigFile
  117. {
  118. get { return m_Bootstrap.StartupConfigFile; }
  119. }
  120. public string BaseDirectory
  121. {
  122. get { return m_Bootstrap.BaseDirectory; }
  123. }
  124. public override object InitializeLifetimeService()
  125. {
  126. //Never expire
  127. return null;
  128. }
  129. }
  130. }