使用YKCDataProtocol处理

This commit is contained in:
Guoqs
2024-11-27 14:44:51 +08:00
parent 390f746928
commit 9d61fa5dba
4 changed files with 136 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
package com.jsowell.netty.service.yunkuaichong;
import io.netty.channel.Channel;
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelId;
@@ -18,6 +18,8 @@ public interface YKCBusinessService {
*/
byte[] process(byte[] msg, ChannelHandlerContext ctx);
byte[] process(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext ctx);
/**
* 桩退出
* @param channelId channelId

View File

@@ -50,6 +50,20 @@ public class YKCBusinessServiceImpl implements YKCBusinessService {
return invokeStrategy.supplyProcess(ykcDataProtocol, ctx);
}
@Override
public byte[] process(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext ctx) {
if (!YKCUtils.checkMsg(ykcDataProtocol)) {
// 校验不通过,丢弃消息
return null;
}
// 获取帧类型
String frameType = YKCUtils.frameType2Str(ykcDataProtocol.getFrameType());
// 获取业务处理handler
AbstractYkcHandler invokeStrategy = YKCOperateFactory.getInvokeStrategy(frameType);
// AbstractYkcHandlerV2 invokeStrategy = ykcOperateFactoryV2.getInvokeStrategy(frameType);
return invokeStrategy.supplyProcess(ykcDataProtocol, ctx);
}
@Override
public void exit(ChannelId channelId) {
// 获取桩编号