Commit 2729ceb7971c4362241dc1c6d19a93eba1fc296d
Merge branch '20230428' into 'master_dev'
fix: 响应信息不存在时,不下发确认消息 See merge request yunteng/thingskit!189
Showing
1 changed file
with
18 additions
and
13 deletions
... | ... | @@ -505,19 +505,21 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements |
505 | 505 | .ifPresent( |
506 | 506 | payload -> { |
507 | 507 | deviceSessionCtx.rpcRequesting(payload.getIdentifier(), rpcRequest); |
508 | - var cf = pushDeviceMsg(deviceSessionCtx.getChannel(), payload.getDatas()); | |
509 | - cf.addListener( | |
510 | - result -> { | |
511 | - if (result.cause() == null) { | |
512 | - transportService.process( | |
513 | - deviceSessionCtx.getSessionInfo(), | |
514 | - rpcRequest, | |
515 | - RpcStatus.DELIVERED, | |
516 | - TransportServiceCallback.EMPTY); | |
517 | - } else { | |
518 | - // TODO: send error | |
519 | - } | |
520 | - }); | |
508 | + Optional.ofNullable(pushDeviceMsg(deviceSessionCtx.getChannel(), payload.getDatas())).ifPresent(cf->{ | |
509 | + cf.addListener( | |
510 | + result -> { | |
511 | + if (result.cause() == null) { | |
512 | + transportService.process( | |
513 | + deviceSessionCtx.getSessionInfo(), | |
514 | + rpcRequest, | |
515 | + RpcStatus.DELIVERED, | |
516 | + TransportServiceCallback.EMPTY); | |
517 | + } else { | |
518 | + // TODO: send error | |
519 | + } | |
520 | + }); | |
521 | + }); | |
522 | + ; | |
521 | 523 | }); |
522 | 524 | } catch (Exception e) { |
523 | 525 | transportService.process(deviceSessionCtx.getSessionInfo(), |
... | ... | @@ -540,6 +542,9 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements |
540 | 542 | * @return |
541 | 543 | */ |
542 | 544 | private ChannelFuture pushDeviceMsg(ChannelHandlerContext ctx, String message) { |
545 | + if(StringUtils.isBlank(message)){ | |
546 | + return null; | |
547 | + } | |
543 | 548 | ByteBuf buff = Unpooled.buffer(); |
544 | 549 | if(!message.matches("-?[0-9a-fA-F]+")){ |
545 | 550 | //不满足16进制将字符串转为16进制 | ... | ... |