1、修改ping应答的bug
This commit is contained in:
parent
a5d76073f6
commit
6f01e78368
@ -1,6 +1,7 @@
|
|||||||
package com.imdroid.sideslope.executor;
|
package com.imdroid.sideslope.executor;
|
||||||
|
|
||||||
import com.imdroid.sideslope.message.D314PingMessage;
|
import com.imdroid.sideslope.message.D314PingMessage;
|
||||||
|
import com.imdroid.sideslope.server.DeviceChannel;
|
||||||
import com.imdroid.sideslope.server.OnlineChannels;
|
import com.imdroid.sideslope.server.OnlineChannels;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
@ -17,12 +18,13 @@ public class D314PingMessageExecutor implements Executor<D314PingMessage, Void>
|
|||||||
public Void execute(D314PingMessage message) {
|
public Void execute(D314PingMessage message) {
|
||||||
String deviceId = message.getId();
|
String deviceId = message.getId();
|
||||||
byte[] forwardBytes = message.getSrcData();
|
byte[] forwardBytes = message.getSrcData();
|
||||||
OnlineChannels.INSTANCE.get(deviceId).ifPresent(deviceChannel -> {
|
DeviceChannel deviceChannel = OnlineChannels.INSTANCE.getConfigChannel(deviceId);
|
||||||
forwardBytes[12] = (byte) 1;//ping ack
|
if(deviceChannel!=null){
|
||||||
|
//forwardBytes[12] = (byte) 1;//ping ack
|
||||||
ByteBuf buf = Unpooled.buffer();
|
ByteBuf buf = Unpooled.buffer();
|
||||||
buf.writeBytes(forwardBytes);
|
buf.writeBytes(forwardBytes);
|
||||||
deviceChannel.writeAndFlush(buf);
|
deviceChannel.writeAndFlush(buf);
|
||||||
});
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,12 +3,9 @@ package com.imdroid.sideslope.server;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Layton
|
* @author Layton
|
||||||
@ -62,10 +59,6 @@ public class OnlineChannels {
|
|||||||
return Optional.ofNullable(dataChannels.get(deviceId));
|
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){
|
public DeviceChannel getDataChannel(String deviceId){
|
||||||
return dataChannels.get(deviceId);
|
return dataChannels.get(deviceId);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user