Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
System.Net.WebSockets.ManagedWebSocket Class Referencesealed

Classes

struct  _003CEnsureBufferContainsAsync_003Ed__74
 
struct  _003CReceiveAsyncPrivate_003Ed__63
 
struct  MessageHeader
 
class  Utf8MessageState
 

Public Member Functions

override void Dispose ()
 
override Task SendAsync (ArraySegment< byte > buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken)
 
override ValueTask SendAsync (ReadOnlyMemory< byte > buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken)
 
override ValueTask SendAsync (ReadOnlyMemory< byte > buffer, WebSocketMessageType messageType, WebSocketMessageFlags messageFlags, CancellationToken cancellationToken)
 
override Task< WebSocketReceiveResultReceiveAsync (ArraySegment< byte > buffer, CancellationToken cancellationToken)
 
override ValueTask< ValueWebSocketReceiveResultReceiveAsync (Memory< byte > buffer, CancellationToken cancellationToken)
 
override Task CloseAsync (WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
 
override Task CloseOutputAsync (WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
 
override void Abort ()
 
Task CloseAsync (WebSocketCloseStatus closeStatus, string? statusDescription, CancellationToken cancellationToken)
 
Task CloseOutputAsync (WebSocketCloseStatus closeStatus, string? statusDescription, CancellationToken cancellationToken)
 

Static Public Member Functions

static ArraySegment< byte > CreateClientBuffer (int receiveBufferSize, int sendBufferSize)
 
static ArraySegment< byte > CreateServerBuffer (int receiveBufferSize)
 
static WebSocket CreateFromStream (Stream stream, bool isServer, string? subProtocol, TimeSpan keepAliveInterval)
 
static WebSocket CreateFromStream (Stream stream, WebSocketCreationOptions options)
 
static bool IsApplicationTargeting45 ()
 
static void RegisterPrefixes ()
 
static WebSocket CreateClientWebSocket (Stream innerStream, string? subProtocol, int receiveBufferSize, int sendBufferSize, TimeSpan keepAliveInterval, bool useZeroMaskingKey, ArraySegment< byte > internalBuffer)
 

Static Protected Member Functions

static void ThrowOnInvalidState (WebSocketState state, params WebSocketState[] validStates)
 
static bool IsStateTerminal (WebSocketState state)
 

Package Functions

 ManagedWebSocket (Stream stream, bool isServer, string subprotocol, TimeSpan keepAliveInterval)
 
 ManagedWebSocket (Stream stream, WebSocketCreationOptions options)
 

Properties

object StateUpdateLock [get]
 
override? WebSocketCloseStatus CloseStatus [get]
 
override string CloseStatusDescription [get]
 
override WebSocketState State [get]
 
override string SubProtocol [get]
 
static TimeSpan DefaultKeepAliveInterval [get]
 

Private Types

enum  MessageOpcode : byte {
  Continuation = 0 , Text = 1 , Binary = 2 , Close = 8 ,
  Ping = 9 , Pong = 10
}
 

Private Member Functions

void DisposeCore ()
 
async Task CloseOutputAsyncCore (WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
 
void OnAborted ()
 
ValueTask SendFrameAsync (MessageOpcode opcode, bool endOfMessage, bool disableCompression, ReadOnlyMemory< byte > payloadBuffer, CancellationToken cancellationToken)
 
ValueTask SendFrameLockAcquiredNonCancelableAsync (MessageOpcode opcode, bool endOfMessage, bool disableCompression, ReadOnlyMemory< byte > payloadBuffer)
 
async ValueTask WaitForWriteTaskAsync (ValueTask writeTask)
 
async ValueTask SendFrameFallbackAsync (MessageOpcode opcode, bool endOfMessage, bool disableCompression, ReadOnlyMemory< byte > payloadBuffer, Task lockTask, CancellationToken cancellationToken)
 
int WriteFrameToSendBuffer (MessageOpcode opcode, bool endOfMessage, bool disableCompression, ReadOnlySpan< byte > payloadBuffer)
 
void SendKeepAliveFrameAsync ()
 
ValueTask< TResultReceiveAsyncPrivate< TResult > (Memory< byte > payloadBuffer, CancellationToken cancellationToken)
 
TResult GetReceiveResult< TResult > (int count, WebSocketMessageType messageType, bool endOfMessage)
 
async ValueTask HandleReceivedCloseAsync (MessageHeader header, CancellationToken cancellationToken)
 
async ValueTask WaitForServerToCloseConnectionAsync (CancellationToken cancellationToken)
 
async ValueTask HandleReceivedPingPongAsync (MessageHeader header, CancellationToken cancellationToken)
 
async ValueTask CloseWithReceiveErrorAndThrowAsync (WebSocketCloseStatus closeStatus, WebSocketError error, string errorMessage=null, Exception innerException=null)
 
string TryParseMessageHeaderFromReceiveBuffer (out MessageHeader resultHeader)
 
async Task CloseAsyncPrivate (WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
 
async ValueTask SendCloseFrameAsync (WebSocketCloseStatus closeStatus, string closeStatusDescription, CancellationToken cancellationToken)
 
void ConsumeFromBuffer (int count)
 
ValueTask EnsureBufferContainsAsync (int minimumRequiredBytes, CancellationToken cancellationToken, bool throwOnPrematureClosure=true)
 
void ThrowIfEOFUnexpected (bool throwOnPrematureClosure)
 
void AllocateSendBuffer (int minLength)
 
void ReleaseSendBuffer ()
 
async ValueTask SendWithArrayPoolAsync (ReadOnlyMemory< byte > buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken)
 

Static Private Member Functions

static int WriteHeader (MessageOpcode opcode, byte[] sendBuffer, ReadOnlySpan< byte > payload, bool endOfMessage, bool useMask, bool compressed)
 
static void WriteRandomMask (byte[] buffer, int offset)
 
static bool IsValidCloseStatus (WebSocketCloseStatus closeStatus)
 
static int CombineMaskBytes (Span< byte > buffer, int maskOffset)
 
static int ApplyMask (Span< byte > toMask, byte[] mask, int maskOffset, int maskOffsetIndex)
 
static unsafe int ApplyMask (Span< byte > toMask, int mask, int maskIndex)
 
static Exception CreateOperationCanceledException (Exception innerException, CancellationToken cancellationToken=default(CancellationToken))
 
static bool TryValidateUtf8 (Span< byte > span, bool endOfMessage, Utf8MessageState state)
 

Private Attributes

readonly Stream _stream
 
readonly bool _isServer
 
readonly string _subprotocol
 
readonly Timer _keepAliveTimer
 
readonly Memory< byte > _receiveBuffer
 
readonly Utf8MessageState _utf8TextState = new Utf8MessageState()
 
readonly AsyncMutex _sendMutex = new AsyncMutex()
 
readonly AsyncMutex _receiveMutex = new AsyncMutex()
 
WebSocketState _state = WebSocketState.Open
 
bool _disposed
 
bool _sentCloseFrame
 
bool _receivedCloseFrame
 
WebSocketCloseStatus_closeStatus
 
string _closeStatusDescription
 
MessageHeader _lastReceiveHeader
 
int _receiveBufferOffset
 
int _receiveBufferCount
 
int _receivedMaskOffsetOffset
 
byte[] _sendBuffer
 
bool _lastSendWasFragment
 
bool _lastSendHadDisableCompression
 
readonly WebSocketInflater _inflater
 
readonly WebSocketDeflater _deflater
 

Static Private Attributes

static readonly UTF8Encoding s_textEncoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true)
 
static readonly WebSocketState[] s_validSendStates
 
static readonly WebSocketState[] s_validReceiveStates
 
static readonly WebSocketState[] s_validCloseOutputStates
 
static readonly WebSocketState[] s_validCloseStates
 

Detailed Description

Definition at line 15 of file ManagedWebSocket.cs.


The documentation for this class was generated from the following file: