TmcIdentity.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using Taobao.Top.Link.Endpoints;
  3. namespace Top.Tmc
  4. {
  5. /// <summary>消息服务客户端标识</summary>
  6. public class TmcClientIdentity : Identity
  7. {
  8. /// <summary>获取appKey
  9. /// </summary>
  10. public string AppKey { get; private set; }
  11. /// <summary>获取groupName
  12. /// </summary>
  13. public string GroupName { get; private set; }
  14. public TmcClientIdentity(string appKey, string groupName)
  15. {
  16. this.AppKey = appKey;
  17. this.GroupName = groupName;
  18. }
  19. public bool Equals(Identity id)
  20. {
  21. var tmcId = id as TmcClientIdentity;
  22. return tmcId != null
  23. && this.AppKey == tmcId.AppKey
  24. && this.GroupName == tmcId.GroupName;
  25. }
  26. public Identity Parse(object data)
  27. {
  28. throw new NotImplementedException();
  29. }
  30. public void Render(object to)
  31. {
  32. }
  33. public override string ToString()
  34. {
  35. return this.AppKey + "-" + this.GroupName;
  36. }
  37. public override int GetHashCode()
  38. {
  39. return (this.AppKey + this.GroupName).GetHashCode();
  40. }
  41. }
  42. /// <summary>TMC服务端标识
  43. /// </summary>
  44. public class TmcServerIdentity : Identity
  45. {
  46. public bool Equals(Identity id)
  47. {
  48. return id is TmcServerIdentity;
  49. }
  50. public Identity Parse(object data)
  51. {
  52. throw new NotImplementedException();
  53. }
  54. public void Render(object to)
  55. {
  56. throw new NotImplementedException();
  57. }
  58. public override string ToString()
  59. {
  60. return "tmc-server";
  61. }
  62. }
  63. }