IService.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //------------------------------------------------------------------------------
  2. // 此代码版权(除特别声明或在XREF结尾的命名空间的代码)归作者本人若汝棋茗所有
  3. // 源代码使用协议遵循本仓库的开源协议及附加协议,若本仓库没有设置,则按MIT开源协议授权
  4. // CSDN博客:https://blog.csdn.net/qq_40374647
  5. // 哔哩哔哩视频:https://space.bilibili.com/94253567
  6. // Gitee源代码仓库:https://gitee.com/RRQM_Home
  7. // Github源代码仓库:https://github.com/RRQM
  8. // API首页:https://www.yuque.com/rrqm/touchsocket/index
  9. // 交流QQ群:234762506
  10. // 感谢您的下载和使用
  11. //------------------------------------------------------------------------------
  12. //------------------------------------------------------------------------------
  13. using System;
  14. using TouchSocket.Core;
  15. namespace TouchSocket.Sockets
  16. {
  17. /// <summary>
  18. /// 服务器接口
  19. /// </summary>
  20. public interface IService : IDisposable
  21. {
  22. /// <summary>
  23. /// 服务器状态
  24. /// </summary>
  25. ServerState ServerState { get; }
  26. /// <summary>
  27. /// 获取服务器配置
  28. /// </summary>
  29. TouchSocketConfig Config { get; }
  30. /// <summary>
  31. /// 名称
  32. /// </summary>
  33. string ServerName { get; }
  34. /// <summary>
  35. /// 配置服务器
  36. /// </summary>
  37. /// <param name="serverConfig">配置</param>
  38. /// <exception cref="Exception"></exception>
  39. /// <returns>设置的服务实例</returns>
  40. IService Setup(TouchSocketConfig serverConfig);
  41. /// <summary>
  42. /// 配置服务器
  43. /// </summary>
  44. /// <param name="port"></param>
  45. /// <exception cref="Exception"></exception>
  46. /// <returns>设置的服务实例</returns>
  47. IService Setup(int port);
  48. /// <summary>
  49. /// 启动
  50. /// </summary>
  51. /// <exception cref="Exception"></exception>
  52. /// <exception cref="ArgumentNullException"></exception>
  53. /// <exception cref="Exception"></exception>
  54. /// <returns>设置的服务实例</returns>
  55. IService Start();
  56. /// <summary>
  57. /// 停止
  58. /// </summary>
  59. /// <exception cref="Exception"></exception>
  60. /// <returns>设置的服务实例</returns>
  61. IService Stop();
  62. }
  63. }