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) { 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); }