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