AChannel.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.IO;
  3. using System.Net;
  4. namespace ET
  5. {
  6. public enum ChannelType
  7. {
  8. Connect,
  9. Accept,
  10. }
  11. public struct Packet
  12. {
  13. public const int MinPacketSize = 2;
  14. public const int OpcodeIndex = 8;
  15. public const int KcpOpcodeIndex = 0;
  16. public const int OpcodeLength = 2;
  17. public const int ActorIdIndex = 0;
  18. public const int ActorIdLength = 8;
  19. public const int MessageIndex = 10;
  20. public ushort Opcode;
  21. public long ActorId;
  22. public MemoryStream MemoryStream;
  23. }
  24. public enum ServiceType
  25. {
  26. Outer,
  27. Inner,
  28. }
  29. public abstract class AChannel: IDisposable
  30. {
  31. public long Id;
  32. public ChannelType ChannelType { get; protected set; }
  33. public int Error { get; set; }
  34. private IPEndPoint remoteAddress;
  35. public IPEndPoint RemoteAddress
  36. {
  37. get
  38. {
  39. return this.remoteAddress;
  40. }
  41. set
  42. {
  43. this.remoteAddress = value;
  44. }
  45. }
  46. public bool IsDisposed
  47. {
  48. get
  49. {
  50. return this.Id == 0;
  51. }
  52. }
  53. public abstract void Dispose();
  54. }
  55. }