Struct DeviceFrame
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
PayloadReadOnlyMemory<byte>MediaTypestring
Properties
MediaType
public string MediaType { get; init; }
Property Value
Payload
public ReadOnlyMemory<byte> Payload { get; init; }
Property Value
Methods
AsText()
Gets the payload as text; the payload must be text.
public string AsText()
Returns
Binary(ReadOnlyMemory<byte>, string)
Creates a binary frame.
public static DeviceFrame Binary(ReadOnlyMemory<byte> payload, string mediaType = "application/octet-stream")
Parameters
payloadReadOnlyMemory<byte>mediaTypestring
Returns
Text(string)
Creates a text frame, UTF-8 encoded.
public static DeviceFrame Text(string text)
Parameters
textstring
Returns
ToString()
A short form for trace attributes and failure messages.
public override string ToString()
Returns
TryGetText(out string)
Gets the payload as text when the frame is textual.
public bool TryGetText(out string text)
Parameters
textstring