From e6238a675c3aa05d8ca6722798e3c5f2f2fcfbc7 Mon Sep 17 00:00:00 2001 From: Patrick Ritchie Date: Thu, 2 Nov 2023 12:21:08 -0400 Subject: [PATCH] Allow Devices file to override Http Client Probe in MQTT Gateway Agents --- .../MTConnectMqttBrokerAgentGatewayApplication.cs | 6 +++++- .../MTConnectMqttRelayAgentGatewayApplication.cs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/MTConnect.NET-Applications-Agents-MQTT/MTConnectMqttBrokerAgentGatewayApplication.cs b/src/MTConnect.NET-Applications-Agents-MQTT/MTConnectMqttBrokerAgentGatewayApplication.cs index 0c8458e2..3450e41f 100644 --- a/src/MTConnect.NET-Applications-Agents-MQTT/MTConnectMqttBrokerAgentGatewayApplication.cs +++ b/src/MTConnect.NET-Applications-Agents-MQTT/MTConnectMqttBrokerAgentGatewayApplication.cs @@ -104,11 +104,15 @@ protected override void OnStartAgentBeforeLoad(IEnumerable agentClient.OnClientStopped += (s, e) => AgentClientStopped(agentClient); agentClient.OnStreamStarted += (s, query) => AgentClientStreamStarted(agentClient, query); agentClient.OnStreamStopped += (s, e) => AgentClientStreamStopped(agentClient); - agentClient.OnProbeReceived += (s, doc) => DevicesDocumentReceived(agentClient, doc); agentClient.OnCurrentReceived += (s, doc) => StreamsDocumentReceived(agentClient, doc); agentClient.OnSampleReceived += (s, doc) => StreamsDocumentReceived(agentClient, doc); agentClient.OnAssetsReceived += (s, doc) => AssetsDocumentReceived(agentClient, doc); + if (Agent.GetDevice(agentClient.Device) == null) + { + agentClient.OnProbeReceived += (s, doc) => DevicesDocumentReceived(agentClient, doc); + } + _clients.Add(agentClient); } } diff --git a/src/MTConnect.NET-Applications-Agents-MQTT/MTConnectMqttRelayAgentGatewayApplication.cs b/src/MTConnect.NET-Applications-Agents-MQTT/MTConnectMqttRelayAgentGatewayApplication.cs index 1982f8c0..1bbb8181 100644 --- a/src/MTConnect.NET-Applications-Agents-MQTT/MTConnectMqttRelayAgentGatewayApplication.cs +++ b/src/MTConnect.NET-Applications-Agents-MQTT/MTConnectMqttRelayAgentGatewayApplication.cs @@ -104,11 +104,15 @@ protected override void OnStartAgentBeforeLoad(IEnumerable agentClient.OnClientStopped += (s, e) => AgentClientStopped(agentClient); agentClient.OnStreamStarted += (s, query) => AgentClientStreamStarted(agentClient, query); agentClient.OnStreamStopped += (s, e) => AgentClientStreamStopped(agentClient); - agentClient.OnProbeReceived += (s, doc) => DevicesDocumentReceived(agentClient, doc); agentClient.OnCurrentReceived += (s, doc) => StreamsDocumentReceived(agentClient, doc); agentClient.OnSampleReceived += (s, doc) => StreamsDocumentReceived(agentClient, doc); agentClient.OnAssetsReceived += (s, doc) => AssetsDocumentReceived(agentClient, doc); + if (Agent.GetDevice(agentClient.Device) == null) + { + agentClient.OnProbeReceived += (s, doc) => DevicesDocumentReceived(agentClient, doc); + } + _clients.Add(agentClient); } }