Commit 2729ceb7971c4362241dc1c6d19a93eba1fc296d

Authored by xp.Huang
2 parents fa1406bc 3858855e

Merge branch '20230428' into 'master_dev'

fix: 响应信息不存在时,不下发确认消息

See merge request yunteng/thingskit!189
@@ -505,19 +505,21 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements @@ -505,19 +505,21 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements
505 .ifPresent( 505 .ifPresent(
506 payload -> { 506 payload -> {
507 deviceSessionCtx.rpcRequesting(payload.getIdentifier(), rpcRequest); 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 } catch (Exception e) { 524 } catch (Exception e) {
523 transportService.process(deviceSessionCtx.getSessionInfo(), 525 transportService.process(deviceSessionCtx.getSessionInfo(),
@@ -540,6 +542,9 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements @@ -540,6 +542,9 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements
540 * @return 542 * @return
541 */ 543 */
542 private ChannelFuture pushDeviceMsg(ChannelHandlerContext ctx, String message) { 544 private ChannelFuture pushDeviceMsg(ChannelHandlerContext ctx, String message) {
  545 + if(StringUtils.isBlank(message)){
  546 + return null;
  547 + }
543 ByteBuf buff = Unpooled.buffer(); 548 ByteBuf buff = Unpooled.buffer();
544 if(!message.matches("-?[0-9a-fA-F]+")){ 549 if(!message.matches("-?[0-9a-fA-F]+")){
545 //不满足16进制将字符串转为16进制 550 //不满足16进制将字符串转为16进制