ServerChannel.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using Top.Api;
  3. namespace Taobao.Top.Link.Channel
  4. {
  5. /// <summary>the channel that server bound
  6. /// </summary>
  7. public abstract class ServerChannel
  8. {
  9. protected ITopLogger Logger { get; private set; }
  10. /// <summary>get server address
  11. /// </summary>
  12. protected int Port { get; private set; }
  13. /// <summary>get or set connection max idle time that do not send or receive
  14. /// </summary>
  15. public int MaxIdleTimeSeconds { get; set; }
  16. /// <summary>while message received on this channel
  17. /// </summary>
  18. public EventHandler<ChannelContext> OnMessage { get; set; }
  19. /// <summary>while error occur on this channel
  20. /// </summary>
  21. public EventHandler<ChannelContext> OnError { get; set; }
  22. public ServerChannel(ITopLogger logger, int port)
  23. {
  24. this.Logger = logger;
  25. this.Port = port;
  26. }
  27. /// <summary>start server
  28. /// </summary>
  29. public abstract void Start();
  30. /// <summary>stop server
  31. /// </summary>
  32. public abstract void Stop();
  33. }
  34. }