Skip to content

Commit

Permalink
support hostname
Browse files Browse the repository at this point in the history
fixes #100
  • Loading branch information
zivillian committed Mar 22, 2024
1 parent 57082dc commit ac1fe7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/ism7mqtt/ISM7/Ism7Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace ism7mqtt
public class Ism7Client
{
private readonly Func<Ism7Config, CancellationToken, Task> _messageHandler;
private readonly IPAddress _ipAddress;
private readonly string _host;
private readonly ConcurrentDictionary<Type, XmlSerializer> _serializers = new ConcurrentDictionary<Type, XmlSerializer>();
private readonly Ism7Config _config;
private readonly Pipe _pipe;
Expand All @@ -37,10 +37,10 @@ public class Ism7Client

public Func<Ism7Config, CancellationToken, Task> OnInitializationFinishedAsync { get; set; }

public Ism7Client(Func<Ism7Config, CancellationToken, Task> messageHandler, string parameterPath, IPAddress ipAddress)
public Ism7Client(Func<Ism7Config, CancellationToken, Task> messageHandler, string parameterPath, string host)
{
_messageHandler = messageHandler;
_ipAddress = ipAddress;
_host = host;
_config = new Ism7Config(parameterPath);
_pipe = new Pipe();
}
Expand All @@ -60,7 +60,7 @@ public async Task RunAsync(string password, CancellationToken cancellationToken)
private async Task<SslStream> ConnectAsync(CancellationToken cancellationToken)
{
var tcp = new TcpClient();
await tcp.ConnectAsync(_ipAddress, 9092, cancellationToken);
await tcp.ConnectAsync(_host, 9092, cancellationToken);
var certificate = new X509Certificate2(Resources.client);
var ssl = new SslStream(tcp.GetStream(), false, (a, b, c, d) => true);

Expand Down Expand Up @@ -274,7 +274,7 @@ private async Task OnPushResponseAsync(IResponse response, CancellationToken can

private async Task LoadInitialValuesAsync(CancellationToken cancellationToken)
{
foreach (var busAddress in _config.AddAllDevices(_ipAddress.ToString()))
foreach (var busAddress in _config.AddAllDevices(_host))
{
var infoReads = _config.GetInfoReadForDevice(busAddress).ToList();
var bundleId = NextBundleId();
Expand Down
2 changes: 1 addition & 1 deletion src/ism7mqtt/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static async Task Main(string[] args)
await mqttClient.ConnectAsync(mqttOptions, cts.Token);
await mqttClient.SubscribeAsync($"Wolf/{ip}/+/set");
await mqttClient.SubscribeAsync($"Wolf/{ip}/+/set/#");
var client = new Ism7Client((config, token) => OnMessage(mqttClient, config, enableDebug, token), parameter, IPAddress.Parse(ip))
var client = new Ism7Client((config, token) => OnMessage(mqttClient, config, enableDebug, token), parameter, ip)
{
Interval = interval,
EnableDebug = enableDebug
Expand Down

0 comments on commit ac1fe7d

Please sign in to comment.