mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-05 18:40:14 +08:00
@@ -8,7 +8,6 @@ import com.jsowell.netty.service.electricbicycles.EBikeBusinessService;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.*;
|
import io.netty.channel.*;
|
||||||
import io.netty.handler.timeout.ReadTimeoutException;
|
import io.netty.handler.timeout.ReadTimeoutException;
|
||||||
import io.netty.util.ReferenceCountUtil;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -61,30 +60,25 @@ public class ElectricBicyclesServerHandler extends ChannelInboundHandlerAdapter
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void channelRead(ChannelHandlerContext ctx, Object message) throws Exception {
|
public void channelRead(ChannelHandlerContext ctx, Object message) throws Exception {
|
||||||
try {
|
byte[] msg = (byte[]) message;
|
||||||
byte[] msg = (byte[]) message;
|
// 处理数据
|
||||||
// 处理数据
|
byte[] response = eBikeService.process(msg, ctx);
|
||||||
byte[] response = eBikeService.process(msg, ctx);
|
if (Objects.nonNull(response)) {
|
||||||
if (Objects.nonNull(response)) {
|
log.info("[电单车===>响应数据]:{}", BytesUtil.binary(response, 16));
|
||||||
log.info("[电单车===>响应数据]:{}", BytesUtil.binary(response, 16));
|
// 响应客户端
|
||||||
// 响应客户端
|
ByteBuf buffer = ctx.alloc().buffer().writeBytes(response);
|
||||||
ByteBuf buffer = ctx.alloc().buffer().writeBytes(response);
|
// this.channelWrite(channel.id(), buffer);
|
||||||
// this.channelWrite(channel.id(), buffer);
|
ctx.writeAndFlush(buffer);
|
||||||
ctx.writeAndFlush(buffer);
|
// if (!CollectionUtils.containsAny(notPrintFrameTypeList, frameType)) {
|
||||||
// if (!CollectionUtils.containsAny(notPrintFrameTypeList, frameType)) {
|
// // 应答帧类型
|
||||||
// // 应答帧类型
|
// byte[] responseFrameTypeBytes = YKCFrameTypeCode.PlatformAnswersRelation.getResponseFrameTypeBytes(frameTypeBytes);
|
||||||
// byte[] responseFrameTypeBytes = YKCFrameTypeCode.PlatformAnswersRelation.getResponseFrameTypeBytes(frameTypeBytes);
|
// String responseFrameType = YKCUtils.frameType2Str(responseFrameTypeBytes);
|
||||||
// String responseFrameType = YKCUtils.frameType2Str(responseFrameTypeBytes);
|
// log.info("【>>>>>平台响应消息>>>>>】channel:{}, 响应帧类型:{}, 响应帧名称:{}, 原帧类型:{}, 原帧名称:{}, 序列号域:{}, response:{}",
|
||||||
// log.info("【>>>>>平台响应消息>>>>>】channel:{}, 响应帧类型:{}, 响应帧名称:{}, 原帧类型:{}, 原帧名称:{}, 序列号域:{}, response:{}",
|
// channel.id(), responseFrameType, YKCFrameTypeCode.getFrameTypeStr(responseFrameType),
|
||||||
// channel.id(), responseFrameType, YKCFrameTypeCode.getFrameTypeStr(responseFrameType),
|
// frameType, YKCFrameTypeCode.getFrameTypeStr(frameType), serialNumber,
|
||||||
// frameType, YKCFrameTypeCode.getFrameTypeStr(frameType), serialNumber,
|
// BytesUtil.binary(response, 16));
|
||||||
// BytesUtil.binary(response, 16));
|
// }
|
||||||
// }
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
ReferenceCountUtil.release(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user