Class SubmitMessageParams
Submit Message Parameters, optionally including message segment information.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public sealed class SubmitMessageParams : TransactionParams<SubmitMessageReceipt>
Remarks
The hedera network does not validate the segment information submitted to a consensus topic. This metadata must be validated upon consumption and there can be gaps and inconsistencies in the resulting mirror HCS stream for the related topic.
Examples
Split a large payload across multiple segments. The SDK fills in the
ParentTransactionId for segment 1 from the returned receipt —
pass that id on each subsequent segment:
// Messages larger than ~4KB must be split into segments. On segment 1,
// leave ParentTransactionId null — the SDK computes it for you and
// returns it via the receipt. Pass that TransactionId as the
// ParentTransactionId on every subsequent segment so the mirror node
// can reassemble them into a single logical message.
const int chunkSize = 4000;
var totalSegments = (int)Math.Ceiling((double)largePayload.Length / chunkSize);
var first = await client.SubmitMessageAsync(new SubmitMessageParams
{
Topic = topic,
Message = largePayload.Slice(0, Math.Min(chunkSize, largePayload.Length)),
SegmentIndex = 1,
TotalSegmentCount = totalSegments
});
for (int i = 1; i < totalSegments; i++)
{
var offset = i * chunkSize;
var length = Math.Min(chunkSize, largePayload.Length - offset);
await client.SubmitMessageAsync(new SubmitMessageParams
{
Topic = topic,
Message = largePayload.Slice(offset, length),
ParentTransactionId = first.TransactionId,
SegmentIndex = i + 1,
TotalSegmentCount = totalSegments
});
}
Properties
| Edit this page View SourceCancellationToken
Optional cancellation token that can interrupt the submission process.
Declaration
public CancellationToken? CancellationToken { get; set; }
Property Value
| Type | Description |
|---|---|
| CancellationToken? |
Message
The value of this message or segment of the message, limited to the 4K total network transaction size.
Declaration
public ReadOnlyMemory<byte> Message { get; set; }
Property Value
| Type | Description |
|---|---|
| ReadOnlyMemory<byte> |
ParentTransactionId
If this is a segment of a larger message, the transaction that created the first segment of the message. This acts as a correlation identifier to coalesce the segments of the message into one.
Declaration
public TransactionId? ParentTransactionId { get; set; }
Property Value
| Type | Description |
|---|---|
| TransactionId |
Remarks
This must be left to be null when sending the first segment of a message. The value of the transaction ID returned from the receipt or record will contain the value associated with this parameter for the first segment. This value must be included in subsequent segments for this message.
SegmentIndex
The index of this segment (one based). Leave as zero (0) to submit an un-segmented message.
Declaration
public int SegmentIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Signatory
The signatory containing any additional private keys or callbacks to meet the key signing requirements for participants.
Declaration
public Signatory? Signatory { get; set; }
Property Value
| Type | Description |
|---|---|
| Signatory |
Topic
The address of the topic for the message.
Declaration
public EntityId Topic { get; set; }
Property Value
| Type | Description |
|---|---|
| EntityId |
TotalSegmentCount
The total number of segments making up the whole of the message when assembled. Set to 0 to indicate that this is not a a segmented message.
Declaration
public int TotalSegmentCount { get; set; }
Property Value
| Type | Description |
|---|---|
| int |