diff --git a/src/Binary/EncodingOptions.cs b/src/Binary/EncodingOptions.cs index eb26b84..5b939f7 100644 --- a/src/Binary/EncodingOptions.cs +++ b/src/Binary/EncodingOptions.cs @@ -8,6 +8,7 @@ namespace opc.ua.pubsub.dotnet.binary public class EncodingOptions : IEquatable { public bool LegacyFieldFlagEncoding { get; set; } + public bool SendMetaMessageWithoutRetain { get; set; } public bool Equals( EncodingOptions other ) { @@ -19,7 +20,9 @@ public bool Equals( EncodingOptions other ) { return true; } - return LegacyFieldFlagEncoding == other.LegacyFieldFlagEncoding; + return + (LegacyFieldFlagEncoding == other.LegacyFieldFlagEncoding) && + (SendMetaMessageWithoutRetain == other.SendMetaMessageWithoutRetain); } public override bool Equals( object obj ) @@ -41,7 +44,12 @@ public override bool Equals( object obj ) public override int GetHashCode() { - return LegacyFieldFlagEncoding.GetHashCode(); + unchecked + { + int hashCode = LegacyFieldFlagEncoding.GetHashCode(); + hashCode = ( hashCode * 397 ) ^ ( SendMetaMessageWithoutRetain.GetHashCode() ); + return hashCode; + } } public static bool operator ==( EncodingOptions left, EncodingOptions right ) diff --git a/src/Client/Client.cs b/src/Client/Client.cs index 74e60de..8e372ae 100644 --- a/src/Client/Client.cs +++ b/src/Client/Client.cs @@ -596,7 +596,8 @@ public bool SendDataSet( ProcessDataSet dataSet, string topicPrefix, bool delta List metaChunks = dataSet.GetChunkedMetaFrame( ChunkSize, Options, m_SequenceNumber++ ); foreach ( byte[] chunk in metaChunks ) { - Publish( chunk, topicPrefix, dataSet.GetWriterId(), "Meta", dataSet.GetDataSetType(), metaChunks.Count == 1 ); + bool retain = ( metaChunks.Count == 1 ) && ( !Options.SendMetaMessageWithoutRetain ); + Publish( chunk, topicPrefix, dataSet.GetWriterId(), "Meta", dataSet.GetDataSetType(), retain ); UpdateLastKeyAndMetaSentTime( dataSet.GetWriterId() ); } }