Refactoring connection to use an idle timeout and automatically close the underlying data channel

This commit is contained in:
2024-03-31 22:29:07 +02:00
parent 967d80ff3f
commit a58af4d75f
16 changed files with 812 additions and 1198 deletions

View File

@@ -111,37 +111,37 @@ namespace AMWD.Protocols.Modbus.Tcp
}
}
/// <inheritdoc cref="ModbusTcpConnection.ReconnectTimeout"/>
/// <inheritdoc cref="ModbusTcpConnection.ConnectTimeout"/>
public TimeSpan ReconnectTimeout
{
get
{
if (connection is ModbusTcpConnection tcpConnection)
return tcpConnection.ReconnectTimeout;
return tcpConnection.ConnectTimeout;
return default;
}
set
{
if (connection is ModbusTcpConnection tcpConnection)
tcpConnection.ReconnectTimeout = value;
tcpConnection.ConnectTimeout = value;
}
}
/// <inheritdoc cref="ModbusTcpConnection.KeepAliveInterval"/>
public TimeSpan KeepAliveInterval
/// <inheritdoc cref="ModbusTcpConnection.IdleTimeout"/>
public TimeSpan IdleTimeout
{
get
{
if (connection is ModbusTcpConnection tcpConnection)
return tcpConnection.KeepAliveInterval;
return tcpConnection.IdleTimeout;
return default;
}
set
{
if (connection is ModbusTcpConnection tcpConnection)
tcpConnection.KeepAliveInterval = value;
tcpConnection.IdleTimeout = value;
}
}
}