Skip to content
Start free evaluation

PDComm.HsmsEvent

Class

One event taken from an HSMS endpoint: a state change, a received message, a failure or an error.

public sealed class HsmsEvent : IDisposable

Call HsmsEvent.GetInfo to find out what happened. For a received message, read the body with HsmsEvent.GetBody, HsmsEvent.TryCopyBody or HsmsEvent.DecodeBody, and answer a primary that expects a reply with HsmsEndpoint.Reply or HsmsWorker.ReplyAsync.

The event owns an immutable native copy of its data, which stays valid after the endpoint is disposed. Dispose the event when you are done; a finalizer releases it if you forget. All members are thread-safe.

Members

DecodeBody

Method

Decodes the body of a received message as a SECS-II item.

public SecsItem? DecodeBody(SecsLimits limits)

Parameters

NameDescription
limitsThe limits the decoded item must satisfy.

Returns

A new item that the caller owns and must dispose, or null when the event has no body.

Notes

  • Throws ObjectDisposedException: The event has been disposed.
  • Throws PdcommException: The body cannot be copied, or it does not decode within limits; see SecsItem.Decode.

Dispose

Method

Releases the event's native data.

public void Dispose()

Calling this method more than once has no effect.

GetBody

Method

Copies the encoded SECS-II body of a received message.

public byte[] GetBody()

Returns

A new array with the body; empty when the message has no body or the event is not a message.

Notes

  • Throws ObjectDisposedException: The event has been disposed.
  • Throws PdcommException: The native copy failed.

GetInfo

Method

Gets the event's kind, header, token and kind-specific values.

public HsmsEventInfo GetInfo()

Returns

A description of the event.

Notes

  • Throws ObjectDisposedException: The event has been disposed.
  • Throws PdcommException: The native call failed.

TryCopyBody

Method

Copies the encoded SECS-II body into a caller-supplied span when it is large enough.

public bool TryCopyBody(Span<byte> destination, out nuint required)

Parameters

NameDescription
destinationThe span that receives the body.
requiredWhen this method returns, the body size in bytes.

Returns

true if the body was copied; false if destination is too small, in which case it is left unchanged.

Notes

  • Throws ObjectDisposedException: The event has been disposed.
  • Throws PdcommException: The native copy failed for a reason other than a short destination.