优化tcp keepalive
This commit is contained in:
parent
547ba4c6d9
commit
dbea53aa75
|
|
@ -177,12 +177,12 @@ class TcpServerDeviceGateway implements DeviceGateway, MonitorSupportDeviceGatew
|
|||
);
|
||||
}))
|
||||
.flatMap(device -> {
|
||||
DeviceSession fSession = sessionRef.get() == null ?
|
||||
sessionManager.getSession(device.getDeviceId()) :
|
||||
sessionRef.get();
|
||||
|
||||
//处理设备上线消息
|
||||
if (message instanceof DeviceOnlineMessage) {
|
||||
DeviceSession fSession = sessionRef.get() == null ?
|
||||
sessionManager.getSession(device.getDeviceId()) :
|
||||
sessionRef.get();
|
||||
|
||||
if (fSession == null) {
|
||||
fSession = new TcpDeviceSession(client.getId(), device, client, getTransport()) {
|
||||
@Override
|
||||
|
|
@ -199,11 +199,15 @@ class TcpServerDeviceGateway implements DeviceGateway, MonitorSupportDeviceGatew
|
|||
sessionRef.set(fSession);
|
||||
sessionManager.register(fSession);
|
||||
}
|
||||
fSession.keepAlive();
|
||||
if (keepaliveTimeout.get() != null) {
|
||||
fSession.setKeepAliveTimeout(keepaliveTimeout.get());
|
||||
}
|
||||
return Mono.empty();
|
||||
}
|
||||
if (fSession != null) {
|
||||
fSession.keepAlive();
|
||||
}
|
||||
//设备下线
|
||||
if (message instanceof DeviceOfflineMessage) {
|
||||
sessionManager.unregister(device.getDeviceId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue