mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-22 03:55:17 +08:00
使用ChannelHandlerContext
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.jsowell.netty.service.yunkuaichong;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelId;
|
||||
|
||||
/**
|
||||
@@ -12,10 +13,10 @@ public interface YKCBusinessService {
|
||||
* 处理桩发来的请求
|
||||
* 不需要应答的返回null
|
||||
* @param msg 请求报文
|
||||
* @param channel 通道信息
|
||||
* @param ctx 通道信息
|
||||
* @return 结果
|
||||
*/
|
||||
byte[] process(byte[] msg, Channel channel);
|
||||
byte[] process(byte[] msg, ChannelHandlerContext ctx);
|
||||
|
||||
/**
|
||||
* 桩退出
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.jsowell.pile.service.PileMsgRecordService;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
import com.jsowell.pile.service.YKCPushCommandService;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelId;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -36,7 +37,7 @@ public class YKCBusinessServiceImpl implements YKCBusinessService {
|
||||
private YKCPushCommandService ykcPushCommandService;
|
||||
|
||||
@Override
|
||||
public byte[] process(byte[] msg, Channel channel) {
|
||||
public byte[] process(byte[] msg, ChannelHandlerContext ctx) {
|
||||
if (!YKCUtils.checkMsg(msg)) {
|
||||
// 校验不通过,丢弃消息
|
||||
return null;
|
||||
@@ -46,7 +47,7 @@ public class YKCBusinessServiceImpl implements YKCBusinessService {
|
||||
String frameType = YKCUtils.frameType2Str(ykcDataProtocol.getFrameType());
|
||||
// 获取业务处理handler
|
||||
AbstractHandler invokeStrategy = YKCOperateFactory.getInvokeStrategy(frameType);
|
||||
return invokeStrategy.supplyProcess(ykcDataProtocol, channel);
|
||||
return invokeStrategy.supplyProcess(ykcDataProtocol, ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user