1、修改ping应答的bug

This commit is contained in:
weidong 2025-08-25 11:31:58 +08:00
parent a5d76073f6
commit 6f01e78368
2 changed files with 5 additions and 10 deletions

View File

@ -1,6 +1,7 @@
package com.imdroid.sideslope.executor;
import com.imdroid.sideslope.message.D314PingMessage;
import com.imdroid.sideslope.server.DeviceChannel;
import com.imdroid.sideslope.server.OnlineChannels;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
@ -17,12 +18,13 @@ public class D314PingMessageExecutor implements Executor<D314PingMessage, Void>
public Void execute(D314PingMessage message) {
String deviceId = message.getId();
byte[] forwardBytes = message.getSrcData();
OnlineChannels.INSTANCE.get(deviceId).ifPresent(deviceChannel -> {
forwardBytes[12] = (byte) 1;//ping ack
DeviceChannel deviceChannel = OnlineChannels.INSTANCE.getConfigChannel(deviceId);
if(deviceChannel!=null){
//forwardBytes[12] = (byte) 1;//ping ack
ByteBuf buf = Unpooled.buffer();
buf.writeBytes(forwardBytes);
deviceChannel.writeAndFlush(buf);
});
}
return null;
}

View File

@ -3,12 +3,9 @@ package com.imdroid.sideslope.server;
import io.netty.channel.Channel;
import java.net.InetSocketAddress;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/**
* @author Layton
@ -62,10 +59,6 @@ public class OnlineChannels {
return Optional.ofNullable(dataChannels.get(deviceId));
}
public List<DeviceChannel> ifPresent(List<String> deviceIds) {
return deviceIds.stream().map(x -> dataChannels.get(x)).filter(Objects::nonNull).collect(Collectors.toList());
}
public DeviceChannel getDataChannel(String deviceId){
return dataChannels.get(deviceId);
}