Skip to content

Commit

Permalink
Allow sending meta frames without retain flag by setting an option (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasSeidenbecher authored Mar 2, 2021
1 parent 7e8ae2a commit 398e108
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/Binary/EncodingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace opc.ua.pubsub.dotnet.binary
public class EncodingOptions : IEquatable<EncodingOptions>
{
public bool LegacyFieldFlagEncoding { get; set; }
public bool SendMetaMessageWithoutRetain { get; set; }

public bool Equals( EncodingOptions other )
{
Expand All @@ -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 )
Expand All @@ -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 )
Expand Down
3 changes: 2 additions & 1 deletion src/Client/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,8 @@ public bool SendDataSet( ProcessDataSet dataSet, string topicPrefix, bool delta
List<byte[]> 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() );
}
}
Expand Down

0 comments on commit 398e108

Please sign in to comment.