1. 网络接收事件增加taskId参数

This commit is contained in:
HuangXin 2023-08-20 12:23:12 +08:00
parent b3e9b79d98
commit 28c904076a
2 changed files with 11 additions and 0 deletions

View File

@ -53,6 +53,7 @@ public class MessageHandler<T> extends SimpleChannelInboundHandler<BaseBinaryPro
public void channelRead0(ChannelHandlerContext ctx, BaseBinaryProtocol<T> message) throws Exception { public void channelRead0(ChannelHandlerContext ctx, BaseBinaryProtocol<T> message) throws Exception {
SocketNotifyEvent notify = new SocketNotifyEvent(this, SocketNotifyEvent notify = new SocketNotifyEvent(this,
ctx.channel(), ctx.channel(),
message.getCommandId(),
SocketEventName.SOCKET_EVT_RECV, SocketEventName.SOCKET_EVT_RECV,
message.getMsgContent().getMsgBody()); message.getMsgContent().getMsgBody());
applicationEventPublisher.publishEvent(notify); applicationEventPublisher.publishEvent(notify);

View File

@ -12,6 +12,7 @@ import org.springframework.context.ApplicationEvent;
@Setter @Setter
@Getter @Getter
public class SocketNotifyEvent extends ApplicationEvent { public class SocketNotifyEvent extends ApplicationEvent {
private int taskId;
/** /**
* The Evt message. * The Evt message.
*/ */
@ -33,10 +34,19 @@ public class SocketNotifyEvent extends ApplicationEvent {
* @param evtType the evt type * @param evtType the evt type
* @param evtMessage the evt message * @param evtMessage the evt message
*/ */
public SocketNotifyEvent(Object source, Channel ctx, int taskId, SocketEventName evtType, Object evtMessage) {
super(source);
this.socketEvent = evtType;
this.evtMessage = evtMessage;
this.ctxChannel = ctx;
this.taskId = taskId;
}
public SocketNotifyEvent(Object source, Channel ctx, SocketEventName evtType, Object evtMessage) { public SocketNotifyEvent(Object source, Channel ctx, SocketEventName evtType, Object evtMessage) {
super(source); super(source);
this.socketEvent = evtType; this.socketEvent = evtType;
this.evtMessage = evtMessage; this.evtMessage = evtMessage;
this.ctxChannel = ctx; this.ctxChannel = ctx;
this.taskId = 0;
} }
} }