mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 19:15:35 +08:00
使用ChannelHandlerContext
This commit is contained in:
@@ -26,7 +26,7 @@ public abstract class AbstractHandler implements InitializingBean {
|
||||
* 执行逻辑
|
||||
* 有应答
|
||||
*/
|
||||
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, Channel channel) {
|
||||
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, ChannelHandlerContext ctx) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jsowell.netty.service.electricbicycles;
|
||||
|
||||
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.PileConnectorInfoService;
|
||||
import com.jsowell.pile.service.PileMsgRecordService;
|
||||
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 YKCBusinessServiceImpl2 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 YKCBusinessServiceImpl2 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