Messages.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. using NTMiner.Core;
  2. using NTMiner.Core.MinerServer;
  3. using NTMiner.Hub;
  4. using NTMiner.User;
  5. using System;
  6. using System.Collections.Generic;
  7. namespace NTMiner {
  8. #region abstract
  9. public abstract class AddEntityCommand<TEntity> : Cmd where TEntity : class, IEntity<Guid> {
  10. protected AddEntityCommand(TEntity input) {
  11. this.Input = input ?? throw new ArgumentNullException(nameof(input));
  12. }
  13. public TEntity Input { get; private set; }
  14. }
  15. public abstract class RemoveEntityCommand : Cmd {
  16. protected RemoveEntityCommand(Guid entityId) {
  17. this.EntityId = entityId;
  18. }
  19. public Guid EntityId { get; private set; }
  20. }
  21. public abstract class UpdateEntityCommand<TEntity> : Cmd where TEntity : class, IEntity<Guid> {
  22. protected UpdateEntityCommand(TEntity input) {
  23. this.Input = input ?? throw new ArgumentNullException(nameof(input));
  24. }
  25. public TEntity Input { get; private set; }
  26. }
  27. #endregion
  28. [MessageType(description: "显式主界面")]
  29. public class ShowMainWindowCommand : Cmd {
  30. public ShowMainWindowCommand(bool isToggle) {
  31. this.IsToggle = isToggle;
  32. }
  33. public bool IsToggle { get; private set; }
  34. }
  35. [MessageType(description: "设置UserAppSetting")]
  36. public class SetUserAppSettingCommand : Cmd {
  37. public SetUserAppSettingCommand(IUserAppSetting appSetting) {
  38. this.AppSetting = appSetting;
  39. }
  40. public IUserAppSetting AppSetting {
  41. get; private set;
  42. }
  43. }
  44. [MessageType(description: "设置LocalAppSetting")]
  45. public class SetLocalAppSettingCommand : Cmd {
  46. public SetLocalAppSettingCommand(IAppSetting appSetting) {
  47. this.AppSetting = appSetting;
  48. }
  49. public IAppSetting AppSetting {
  50. get; private set;
  51. }
  52. }
  53. [MessageType(description: "LocalAppSetting变更后")]
  54. public class LocalAppSettingChangedEvent : SourcedEvent<IAppSetting> {
  55. public LocalAppSettingChangedEvent(PathId targetPathId, IAppSetting source) : base(targetPathId, source) {
  56. }
  57. }
  58. [MessageType(description: "发生了用户活动后")]
  59. public class UserActionEvent : EventBase {
  60. public UserActionEvent() {
  61. }
  62. }
  63. #region KernelOutputKeyword Messages
  64. [MessageType(description: "添加或修改内核输出关键字")]
  65. public class AddOrUpdateKernelOutputKeywordCommand : Cmd {
  66. public AddOrUpdateKernelOutputKeywordCommand(IKernelOutputKeyword input) {
  67. this.Input = input;
  68. }
  69. public IKernelOutputKeyword Input { get; private set; }
  70. }
  71. [MessageType(description: "添加了用户自定义内核输出关键字后")]
  72. public class UserKernelOutputKeywordAddedEvent : SourcedEvent<IKernelOutputKeyword> {
  73. public UserKernelOutputKeywordAddedEvent(PathId targetPathId, IKernelOutputKeyword source) : base(targetPathId, source) {
  74. }
  75. }
  76. [MessageType(description: "更新了用户自定义内核输出关键字后")]
  77. public class UserKernelOutputKeywordUpdatedEvent : SourcedEvent<IKernelOutputKeyword> {
  78. public UserKernelOutputKeywordUpdatedEvent(PathId targetPathId, IKernelOutputKeyword source) : base(targetPathId, source) {
  79. }
  80. }
  81. [MessageType(description: "移除内核输出关键字")]
  82. public class RemoveKernelOutputKeywordCommand : RemoveEntityCommand {
  83. public RemoveKernelOutputKeywordCommand(Guid entityId) : base(entityId) {
  84. }
  85. }
  86. [MessageType(description: "移除了用户自定义内核输出关键字后")]
  87. public class UserKernelOutputKeywordRemovedEvent : SourcedEvent<IKernelOutputKeyword> {
  88. public UserKernelOutputKeywordRemovedEvent(PathId targetPathId, IKernelOutputKeyword source) : base(targetPathId, source) {
  89. }
  90. }
  91. #endregion
  92. #region LocalMessage
  93. [MessageType(description: "记录了本地事件后")]
  94. public class LocalMessageAddedEvent : SourcedEvent<ILocalMessage> {
  95. public LocalMessageAddedEvent(PathId targetPathId, ILocalMessage source, List<ILocalMessage> removes) : base(targetPathId, source) {
  96. this.Removes = removes ?? new List<ILocalMessage>();
  97. }
  98. public List<ILocalMessage> Removes { get; private set; }
  99. }
  100. [MessageType(description: "清空本地消息集")]
  101. public class ClearLocalMessageSetCommand : Cmd {
  102. public ClearLocalMessageSetCommand() { }
  103. }
  104. [MessageType(description: "本地消息集清空后")]
  105. public class LocalMessageSetClearedEvent : EventBase {
  106. public LocalMessageSetClearedEvent() { }
  107. }
  108. #endregion
  109. #region ServerMessage
  110. [MessageType(description: "清空服务器消息集")]
  111. public class ClearServerMessages : Cmd {
  112. public ClearServerMessages() { }
  113. }
  114. [MessageType(description: "服务器消息集清空后")]
  115. public class ServerMessagesClearedEvent : EventBase {
  116. public ServerMessagesClearedEvent() { }
  117. }
  118. [MessageType(description: "接收从服务器得到的服务器消息")]
  119. public class ReceiveServerMessageCommand : Cmd {
  120. public ReceiveServerMessageCommand(List<ServerMessageData> data) {
  121. this.Data = data;
  122. }
  123. public List<ServerMessageData> Data { get; private set; }
  124. }
  125. [MessageType(description: "从服务器获取新的服务器消息")]
  126. public class LoadNewServerMessageCommand : Cmd {
  127. public LoadNewServerMessageCommand() {
  128. this.KnowServerMessageTimestamp = Timestamp.GetTimestamp();
  129. }
  130. public LoadNewServerMessageCommand(long knowServerMessageTimestamp) {
  131. this.KnowServerMessageTimestamp = knowServerMessageTimestamp;
  132. }
  133. public long KnowServerMessageTimestamp { get; private set; }
  134. }
  135. [MessageType(description: "从服务器获取内核输出关键字")]
  136. public class LoadKernelOutputKeywordCommand : Cmd {
  137. public LoadKernelOutputKeywordCommand() {
  138. this.KnowKernelOutputKeywordTimestamp = Timestamp.GetTimestamp();
  139. }
  140. public LoadKernelOutputKeywordCommand(long knowKernelOutputKeywordTimestamp) {
  141. this.KnowKernelOutputKeywordTimestamp = knowKernelOutputKeywordTimestamp;
  142. }
  143. public long KnowKernelOutputKeywordTimestamp { get; private set; }
  144. }
  145. [MessageType(description: "服务器Ws服务可用了")]
  146. public class WsServerOkEvent : EventBase {
  147. public WsServerOkEvent() { }
  148. }
  149. [MessageType(description: "从服务器获取到新的服务器消息后")]
  150. public class NewServerMessageLoadedEvent : EventBase {
  151. public NewServerMessageLoadedEvent(LinkedList<ServerMessageData> data) {
  152. this.Data = data;
  153. }
  154. public LinkedList<ServerMessageData> Data { get; private set; }
  155. }
  156. [MessageType(description: "从服务器获取了内核输出关键字后")]
  157. public class KernelOutputKeywordLoadedEvent : EventBase {
  158. public KernelOutputKeywordLoadedEvent(List<KernelOutputKeywordData> data) {
  159. this.Data = data;
  160. }
  161. public List<KernelOutputKeywordData> Data { get; private set; }
  162. }
  163. [MessageType(description: "添加或修改服务器消息")]
  164. public class AddOrUpdateServerMessageCommand : AddEntityCommand<IServerMessage> {
  165. public AddOrUpdateServerMessageCommand(IServerMessage input) : base(input) {
  166. }
  167. }
  168. [MessageType(description: "标记删除服务器消息")]
  169. public class MarkDeleteServerMessageCommand : RemoveEntityCommand {
  170. public MarkDeleteServerMessageCommand(Guid id) : base(id) {
  171. }
  172. }
  173. #endregion
  174. [MessageType(description: "矿工集已初始化完成")]
  175. public class ClientSetInitedEvent : EventBase {
  176. public ClientSetInitedEvent() { }
  177. }
  178. [MessageType(description: "用户集已初始化完成")]
  179. public class UserSetInitedEvent : EventBase {
  180. public UserSetInitedEvent() { }
  181. }
  182. [MessageType(description: "Gpu名称集已初始化完成")]
  183. public class GpuNameSetInitedEvent : EventBase {
  184. public GpuNameSetInitedEvent() { }
  185. }
  186. [MessageType(description: "矿机签名集已初始化完成")]
  187. public class MinerSignSetInitedEvent: EventBase {
  188. public MinerSignSetInitedEvent() { }
  189. }
  190. [MessageType(description: "Ws服务器节点地址集已初始化完成")]
  191. public class WsServerNodeAddressSetInitedEvent : EventBase {
  192. public WsServerNodeAddressSetInitedEvent() { }
  193. }
  194. }