protected override Dictionary <string, Action <BasicDeliverEventArgs> > GetPaths() { return(new Dictionary <string, Action <BasicDeliverEventArgs> > { [MqKeyword.SpeedsRoutingKey] = ea => { ClientIdIp[] clientIdIps = MinerClientMqBodyUtil.GetClientIdIpsMqReciveBody(ea.Body); string appId = ea.BasicProperties.AppId; VirtualRoot.RaiseEvent(new SpeedDatasMqEvent(appId, clientIdIps, ea.GetTimestamp())); }, [MqKeyword.MinerSignSetedRoutingKey] = ea => { string appId = ea.BasicProperties.AppId; MinerSign minerSign = MinerClientMqBodyUtil.GetMinerSignMqReceiveBody(ea.Body); if (minerSign != null) { VirtualRoot.RaiseEvent(new MinerSignSetedMqEvent(appId, minerSign, ea.GetTimestamp())); } }, [MqKeyword.QueryClientsForWsRoutingKey] = ea => { string appId = ea.BasicProperties.AppId; string mqMessageId = ea.BasicProperties.MessageId; string loginName = ea.BasicProperties.ReadHeaderString(MqKeyword.LoginNameHeaderName); string sessionId = ea.BasicProperties.ReadHeaderString(MqKeyword.SessionIdHeaderName); QueryClientsForWsRequest query = MinerClientMqBodyUtil.GetQueryClientsForWsMqReceiveBody(ea.Body); if (query != null) { VirtualRoot.Execute(new QueryClientsForWsMqCommand(appId, mqMessageId, ea.GetTimestamp(), loginName, sessionId, query)); } } }); }
public override bool Go(BasicDeliverEventArgs ea) { switch (ea.RoutingKey) { // 上报的算力放在这里消费,因为只有WebApiServer消费该类型的消息,WsServer不消费该类型的消息 case MqKeyword.SpeedRoutingKey: { Guid clientId = MinerClientMqBodyUtil.GetClientIdMqReciveBody(ea.Body); DateTime timestamp = Timestamp.FromTimestamp(ea.BasicProperties.Timestamp.UnixTime); string appId = ea.BasicProperties.AppId; string minerIp = ea.BasicProperties.ReadHeaderString(MqKeyword.MinerIpHeaderName); VirtualRoot.RaiseEvent(new SpeedDataMqEvent(appId, clientId, minerIp, timestamp)); } break; case MqKeyword.ChangeMinerSignRoutingKey: { string appId = ea.BasicProperties.AppId; MinerSign minerSign = MinerClientMqBodyUtil.GetChangeMinerSignMqReceiveBody(ea.Body); if (minerSign != null) { VirtualRoot.Execute(new ChangeMinerSignMqCommand(appId, minerSign)); } } break; case MqKeyword.QueryClientsForWsRoutingKey: { DateTime timestamp = Timestamp.FromTimestamp(ea.BasicProperties.Timestamp.UnixTime); string appId = ea.BasicProperties.AppId; string mqMessageId = ea.BasicProperties.MessageId; string loginName = ea.BasicProperties.ReadHeaderString(MqKeyword.LoginNameHeaderName); string sessionId = ea.BasicProperties.ReadHeaderString(MqKeyword.SessionIdHeaderName); QueryClientsForWsRequest query = MinerClientMqBodyUtil.GetQueryClientsForWsMqReceiveBody(ea.Body); if (query != null) { VirtualRoot.Execute(new QueryClientsForWsMqCommand(appId, mqMessageId, timestamp, loginName, sessionId, query)); } } break; default: return(false); } return(true); }
public override bool Go(BasicDeliverEventArgs ea) { switch (ea.RoutingKey) { case MqKeyword.SpeedsRoutingKey: { ClientIdIp[] clientIdIps = MinerClientMqBodyUtil.GetClientIdIpsMqReciveBody(ea.Body); DateTime timestamp = Timestamp.FromTimestamp(ea.BasicProperties.Timestamp.UnixTime); string appId = ea.BasicProperties.AppId; VirtualRoot.RaiseEvent(new SpeedDatasMqEvent(appId, clientIdIps, timestamp)); } break; case MqKeyword.MinerSignSetedRoutingKey: { string appId = ea.BasicProperties.AppId; DateTime timestamp = Timestamp.FromTimestamp(ea.BasicProperties.Timestamp.UnixTime); MinerSign minerSign = MinerClientMqBodyUtil.GetMinerSignMqReceiveBody(ea.Body); if (minerSign != null) { VirtualRoot.RaiseEvent(new MinerSignSetedMqEvent(appId, minerSign, timestamp)); } } break; case MqKeyword.QueryClientsForWsRoutingKey: { DateTime timestamp = Timestamp.FromTimestamp(ea.BasicProperties.Timestamp.UnixTime); string appId = ea.BasicProperties.AppId; string mqMessageId = ea.BasicProperties.MessageId; string loginName = ea.BasicProperties.ReadHeaderString(MqKeyword.LoginNameHeaderName); string sessionId = ea.BasicProperties.ReadHeaderString(MqKeyword.SessionIdHeaderName); QueryClientsForWsRequest query = MinerClientMqBodyUtil.GetQueryClientsForWsMqReceiveBody(ea.Body); if (query != null) { VirtualRoot.Execute(new QueryClientsForWsMqCommand(appId, mqMessageId, timestamp, loginName, sessionId, query)); } } break; default: return(false); } return(true); }