Class
WebSocketMessage

A WebSocketMessage stores a single frame of a single WebSocket message http://tools.ietf.org/html/rfc6455

Definition

Namespace:Fiddler

Assembly:FiddlerCore.dll

Syntax:

cs-api-definition
public class WebSocketMessage

Inheritance: objectWebSocketMessage

Inherited Members object.GetType()object.MemberwiseClone()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()

Constructors

WebSocketMessage(byte[], bool, DateTime, int, int)

Creates a WebSocket message. Used when importing message from a HAR file.

Declaration

cs-api-definition
public WebSocketMessage(byte[] payload, bool isOutBound, DateTime time, int opcode, int id)

Parameters

payload

byte[]

The payload data as byte array

isOutBound

bool

Message sent by the client

time

DateTime

Message received time

opcode

int

Websocket frame type

id

int

Websocket message id

Fields

Timers

The WebSocketTimers collection tracks the timestamps for this message

Declaration

cs-api-definition
public WebSocketTimers Timers

Field Value

WebSocketTimers

Properties

FrameType

Declaration

cs-api-definition
public WebSocketFrameTypes FrameType { get; }

Property Value

WebSocketFrameTypes

ID

Declaration

cs-api-definition
public int ID { get; }

Property Value

int

IsFinalFrame

Declaration

cs-api-definition
public bool IsFinalFrame { get; }

Property Value

bool

IsOutbound

Declaration

cs-api-definition
[CodeDescription("Returns TRUE if this is a Client->Server message, FALSE if this is a message from Server->Client.")]
public bool IsOutbound { get; }

Property Value

bool

MaskingKey

Declaration

cs-api-definition
[CodeDescription("Returns the WebSocketMessage's masking key, if any.")]
public byte[] MaskingKey { get; }

Property Value

byte[]

PayloadData

Declaration

cs-api-definition
[CodeDescription("Returns the raw payload data, which may be masked.")]
public byte[] PayloadData { get; }

Property Value

byte[]

PayloadLength

Declaration

cs-api-definition
public int PayloadLength { get; }

Property Value

int

WasAborted

Declaration

cs-api-definition
[CodeDescription("Indicates whether this WebSocketMessage was aborted.")]
public bool WasAborted { get; }

Property Value

bool

iCloseReason

If this is a Close frame, returns the close code. Otherwise, returns -1

Declaration

cs-api-definition
[CodeDescription("If this is a Close frame, returns the close code. Otherwise, returns -1.")]
public int iCloseReason { get; }

Property Value

int

Methods

Abort()

Declaration

cs-api-definition
[CodeDescription("Cancel transmission of this WebSocketMessage.")]
public void Abort()

PayloadAsBytes()

Copy the WebSocketMessage's payload into a new Byte Array.

Declaration

cs-api-definition
[CodeDescription("Returns the WebSocketMessage's payload as byte[], unmasking if needed.")]
public byte[] PayloadAsBytes()

Returns

byte[]

A new byte array containing the (unmasked) payload.

PayloadAsString(bool)

Return the WebSocketMessage's payload as a string.

Declaration

cs-api-definition
[CodeDescription("Returns the WebSocketMessage's payload as a string, unmasking if needed.")]
public string PayloadAsString(bool forceText = false)

Parameters

forceText

bool

Force decoding the message data as text even if message type is binary

Returns

string

SetPayload(byte[])

Copies the provided byte array over the WebSocketMessage's payload, masking if needed.

Declaration

cs-api-definition
[CodeDescription("Replaces the WebSocketMessage's payload with the specified byte array, masking if needed.")]
public void SetPayload(byte[] arrNewPayload)

Parameters

arrNewPayload

byte[]

SetPayload(string)

Replaces the WebSocketMessage's payload with the specified string, masking if needed.

Declaration

cs-api-definition
[CodeDescription("Replaces the WebSocketMessage's payload with the specified string, masking if needed.")]
public void SetPayload(string sPayload)

Parameters

sPayload

string

ToByteArray()

Declaration

cs-api-definition
[CodeDescription("Returns the entire WebSocketMessage, including headers.")]
public byte[] ToByteArray()

Returns

byte[]

ToString()

Declaration

cs-api-definition
[CodeDescription("Returns all info about this message.")]
public override string ToString()

Returns

string

Overrides object.ToString()