Struct WebSocketMessage
Represents a WebSocket message containing an encoding and a buffer of bytes.
public readonly struct WebSocketMessage
- Inherited Members
- Extension Methods
Constructors
WebSocketMessage(Encoding, ArraySegment<byte>)
Represents a WebSocket message containing an encoding and a buffer of bytes.
public WebSocketMessage(Encoding encoding, ArraySegment<byte> buffer)
Parameters
encoding
Encodingbuffer
ArraySegment<byte>
Properties
Buffer
Gets the buffer containing the message data.
public ArraySegment<byte> Buffer { get; }
Property Value
Encoding
Gets the encoding used to decode the message.
public Encoding Encoding { get; }
Property Value
Methods
AsObject()
Deserializes the message string into a dynamic object.
public dynamic AsObject()
Returns
- dynamic
The deserialized object.
AsObject<T>()
Deserializes the message string into an object of type T
.
public T AsObject<T>()
Returns
- T
The deserialized object of type
T
.
Type Parameters
T
The type to deserialize the message into.
AsReader()
Creates a Newtonsoft.Json.JsonTextReader to read the message as JSON.
public JsonTextReader AsReader()
Returns
- JsonTextReader
A Newtonsoft.Json.JsonTextReader for the message.
AsString()
Converts the message buffer into a string using the associated encoding.
public string AsString()
Returns
- string
The message as a string.