IWorkItem.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using SuperSocket.SocketBase.Config;
  6. using SuperSocket.SocketBase.Provider;
  7. namespace SuperSocket.SocketBase
  8. {
  9. /// <summary>
  10. /// An item can be started and stopped
  11. /// </summary>
  12. public interface IWorkItemBase : IStatusInfoSource, ISystemEndPoint
  13. {
  14. /// <summary>
  15. /// Gets the name.
  16. /// </summary>
  17. string Name { get; }
  18. /// <summary>
  19. /// Gets the server's config.
  20. /// </summary>
  21. /// <value>
  22. /// The server's config.
  23. /// </value>
  24. IServerConfig Config { get; }
  25. /// <summary>
  26. /// Starts this server instance.
  27. /// </summary>
  28. /// <returns>return true if start successfull, else false</returns>
  29. bool Start();
  30. /// <summary>
  31. /// Reports the potential configuration change.
  32. /// </summary>
  33. /// <param name="config">The server config which may be changed.</param>
  34. void ReportPotentialConfigChange(IServerConfig config);
  35. /// <summary>
  36. /// Stops this server instance.
  37. /// </summary>
  38. void Stop();
  39. /// <summary>
  40. /// Gets the total session count.
  41. /// </summary>
  42. int SessionCount { get; }
  43. }
  44. /// <summary>
  45. /// An item can be started and stopped
  46. /// </summary>
  47. public interface IWorkItem : IWorkItemBase, IStatusInfoSource
  48. {
  49. /// <summary>
  50. /// Setups with the specified root config.
  51. /// </summary>
  52. /// <param name="bootstrap">The bootstrap.</param>
  53. /// <param name="config">The socket server instance config.</param>
  54. /// <param name="factories">The factories.</param>
  55. /// <returns></returns>
  56. bool Setup(IBootstrap bootstrap, IServerConfig config, ProviderFactoryInfo[] factories);
  57. /// <summary>
  58. /// Gets the current state of the work item.
  59. /// </summary>
  60. /// <value>
  61. /// The state.
  62. /// </value>
  63. ServerState State { get; }
  64. }
  65. }