From 873aff5be114114abbcd6cb1b4e13d066e2c5771 Mon Sep 17 00:00:00 2001 From: Martin Regen Date: Thu, 20 Oct 2016 09:36:42 +0200 Subject: [PATCH] add hostname to published data --- .../Samples/NetCoreConsolePublisher/Program.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/SampleApplications/Samples/NetCoreConsolePublisher/Program.cs b/SampleApplications/Samples/NetCoreConsolePublisher/Program.cs index 224ca57195..32f48456ec 100644 --- a/SampleApplications/Samples/NetCoreConsolePublisher/Program.cs +++ b/SampleApplications/Samples/NetCoreConsolePublisher/Program.cs @@ -217,6 +217,12 @@ namespace NetCoreConsolePublisher JsonEncoder encoder = new JsonEncoder( monitoredItem.Subscription.Session.MessageContext, false); + string hostname = monitoredItem.Subscription.Session.ConfiguredEndpoint.EndpointUrl.DnsSafeHost; + if (hostname == "localhost") + { + hostname = Utils.GetHostName(); + } + encoder.WriteString("HostName", hostname); encoder.WriteNodeId("MonitoredItem", monitoredItem.ResolvedNodeId); e.NotificationValue.Encode(encoder);