Ejemplo n.º 1
0
 public WsServerNodeAddressSet(IWsServerNodeRedis wsServerNodeRedis, IWsServerNodeMqSender wsServerNodeMqSender) : base(wsServerNodeRedis)
 {
     _wsServerNodeRedis    = wsServerNodeRedis;
     _wsServerNodeMqSender = wsServerNodeMqSender;
     VirtualRoot.BuildOnecePath <WebSocketServerStatedEvent>("上报节点信息,获取节点列表", LogEnum.UserConsole, PathId.Empty, this.GetType(), PathPriority.Normal, path: _ => {
         ReportNodeAsync(callback: () => {
             base.Init(callback: () => {
                 NTMinerConsole.UserOk("Ws服务器节点地址集初始化完成");
                 VirtualRoot.RaiseEvent(new WsServerNodeAddressSetInitedEvent());
             });
             _wsServerNodeMqSender.SendWsServerNodeAdded();
         });
         VirtualRoot.BuildEventPath <Per10SecondEvent>("节点呼吸", LogEnum.UserConsole, this.GetType(), PathPriority.Normal, path: message => {
             ReportNodeAsync();
         });
     });
 }
Ejemplo n.º 2
0
 public WsServerNodeAddressSet(IWsServerNodeRedis wsServerNodeRedis, IWsServerNodeMqSender wsServerNodeMqSender) : base(wsServerNodeRedis)
 {
     _wsServerNodeRedis    = wsServerNodeRedis;
     _wsServerNodeMqSender = wsServerNodeMqSender;
     VirtualRoot.BuildOnecePath <WebSocketServerStatedEvent>("WebSocket服务启动后上报节点信息,获取节点列表", LogEnum.UserConsole, path: _ => {
         ReportNodeAsync(callback: () => {
             base.Init(callback: () => {
                 NTMinerConsole.UserOk("Ws服务器节点地址集初始化完成");
                 VirtualRoot.RaiseEvent(new WsServerNodeAddressSetInitedEvent());
             });
             _wsServerNodeMqSender.SendWsServerNodeAdded(ServerRoot.HostConfig.ThisServerAddress);
         });
         VirtualRoot.BuildEventPath <Per10SecondEvent>("节点呼吸", LogEnum.UserConsole, path: message => {
             ReportNodeAsync();
         }, this.GetType());
         VirtualRoot.BuildEventPath <Per1MinuteEvent>("打扫", LogEnum.DevConsole, path: message => {
             VirtualRoot.RaiseEvent(new CleanTimeArrivedEvent(AsEnumerable().ToArray()));
         }, this.GetType());
     }, PathId.Empty, this.GetType());
 }
Ejemplo n.º 3
0
 public void SetNodeState(WsServerNodeState data)
 {
     if (data == null || string.IsNullOrEmpty(data.Address))
     {
         return;
     }
     if (!data.IsAddressValid())
     {
         return;
     }
     if (_dicByIp.TryGetValue(data.Address, out WsServerNodeActiveOn nodeData))
     {
         nodeData.Update(data);
     }
     else
     {
         nodeData = WsServerNodeActiveOn.Create(data);
         _dicByIp.Add(data.Address, nodeData);
         ReSetConsistentHash();
         _mqSender.SendWsServerNodeAdded(data.Address);
     }
 }