Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sending meta frames without retain flag by setting an option #12

Merged
merged 1 commit into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -593,7 +593,8 @@ public bool SendDataSet( ProcessDataSet dataSet, string topicPrefix, bool delta
List<byte[]> metaChunks = dataSet.GetChunkedMetaFrame( ChunkSize, Options, 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