You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Service.Charger.Client;
using Service.Charger.Common;
using Service.Charger.Msg.Charger.Req;
using Service.Charger.Msg.Host.Resp;
namespace Service.Charger.Handler
{
//TODO::心跳的Order 应该是多少
[Order(8)]
[Scope("InstancePerDependency")]
public class HeartBeatHandler : SimpleChannelInboundHandler<HeartBeat>, IBaseHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(HeartBeatHandler));
protected override void ChannelRead0(IChannelHandlerContext ctx, HeartBeat msg)
{
if (ClientMgr.TryGetClient(ctx.Channel, out var sn, out var client))
{
//心跳存储日志
Log.Info($"receive {msg} from {sn}");
//心跳桩状态
client.PileState = msg.Status;
//监控平台心跳应答0-正常、1-未注册
HeartBeatRes heartBeatRes = new HeartBeatRes(0);
ctx.Channel.WriteAndFlushAsync(heartBeatRes);
}
}
}
}