AChannel.cs 827 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 abstract class AChannel: IDisposable
  25. {
  26. public long Id;
  27. public ChannelType ChannelType { get; protected set; }
  28. public int Error { get; set; }
  29. public IPEndPoint RemoteAddress { get; set; }
  30. public bool IsDisposed
  31. {
  32. get
  33. {
  34. return this.Id == 0;
  35. }
  36. }
  37. public abstract void Dispose();
  38. }
  39. }