Table of Contents

Struct WebSocketMessage

Namespace
Ecng.Net
Assembly
Ecng.Net.SocketIO.dll

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 Encoding
buffer ArraySegment<byte>

Properties

Buffer

Gets the buffer containing the message data.

public ArraySegment<byte> Buffer { get; }

Property Value

ArraySegment<byte>

Encoding

Gets the encoding used to decode the message.

public Encoding Encoding { get; }

Property Value

Encoding

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.