Struct DeviceFrame

Namespace
ProtoTest.Devices
Assembly
ProtoTest.Devices.dll

One device frame, as bytes plus a media type. OCPP is text JSON, MQTT payloads are binary, so bytes are the neutral unit; the text helpers cover the common protocol.

public readonly record struct DeviceFrame : IEquatable<DeviceFrame>
Implements
Inherited Members
Extension Methods

Constructors

DeviceFrame(ReadOnlyMemory<byte>, string)

One device frame, as bytes plus a media type. OCPP is text JSON, MQTT payloads are binary, so bytes are the neutral unit; the text helpers cover the common protocol.

public DeviceFrame(ReadOnlyMemory<byte> Payload, string MediaType = "text/plain")

Parameters

Payload ReadOnlyMemory<byte>
MediaType string

Properties

MediaType

public string MediaType { get; init; }

Property Value

string

Payload

public ReadOnlyMemory<byte> Payload { get; init; }

Property Value

ReadOnlyMemory<byte>

Methods

AsText()

Gets the payload as text; the payload must be text.

public string AsText()

Returns

string

Binary(ReadOnlyMemory<byte>, string)

Creates a binary frame.

public static DeviceFrame Binary(ReadOnlyMemory<byte> payload, string mediaType = "application/octet-stream")

Parameters

payload ReadOnlyMemory<byte>
mediaType string

Returns

DeviceFrame

Text(string)

Creates a text frame, UTF-8 encoded.

public static DeviceFrame Text(string text)

Parameters

text string

Returns

DeviceFrame

ToString()

A short form for trace attributes and failure messages.

public override string ToString()

Returns

string

TryGetText(out string)

Gets the payload as text when the frame is textual.

public bool TryGetText(out string text)

Parameters

text string

Returns

bool