161 global::Interop.WebSocket.Buffer
value =
default(global::Interop.
WebSocket.Buffer);
164 value.Data.BufferLength = (uint)
buffer.Value.Count;
199 if (
base.AsyncOperationCompleted)
228 global::Interop.WebSocket.Buffer
value =
default(global::Interop.
WebSocket.Buffer);
237 value.CloseStatus.CloseStatus = (ushort)
CloseStatus;
286 global::Interop.WebSocket.Buffer[]
array =
new global::Interop.WebSocket.Buffer[
BufferCount];
531 return watch.Elapsed;
1670 System.
Net.
NetEventSource.
Info(
this,
$"closeStatus: {closeStatus}, closeStatusDescription: {closeStatusDescription}, _State: {_state}",
"FinishOnCloseReceived");
1692 thisPtr.EnsureKeepAliveOperation();
1705 thisPtr._keepAliveTask =
null;
1707 thisPtr._keepAliveTracker.ResetTimer();
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
void Add(TKey key, TValue value)
Task WriteAsync(byte[] buffer, int offset, int count)
Task< int > ReadAsync(byte[] buffer, int offset, int count)
static byte Min(byte val1, byte val2)
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)
static void Associate(object first, object second, [CallerMemberName] string memberName=null)
static void DumpBuffer(object thisOrContextObject, byte[] buffer, int offset, int count, [CallerMemberName] string memberName=null)
static void ValidateOptions(string subProtocol, int receiveBufferSize, int sendBufferSize, TimeSpan keepAliveInterval)
static void ValidateInnerStream(Stream innerStream)
static void ThrowIfConnectionAborted(Stream connection, bool read)
TimeSpan GetTimeElapsed(Stopwatch watch)
void ResetTimer(int dueInMilliseconds)
readonly Stopwatch _lastSendActivity
readonly TimeSpan _keepAliveInterval
override bool ShouldSendKeepAlive()
readonly Stopwatch _lastReceiveActivity
override void ResetTimer()
DefaultKeepAliveTracker(TimeSpan keepAliveInterval)
static readonly TimerCallback s_KeepAliveTimerElapsedCallback
override void OnDataSent()
override void StartTimer(WebSocketBase webSocket)
override void OnDataReceived()
override void OnDataReceived()
override void OnDataSent()
override void ResetTimer()
override void StartTimer(WebSocketBase webSocket)
override bool ShouldSendKeepAlive()
bool ShouldSendKeepAlive()
void StartTimer(WebSocketBase webSocket)
static KeepAliveTracker Create(TimeSpan keepAliveInterval)
bool TryStartOperation(CancellationToken userCancellationToken, out CancellationToken linkedCancellationToken)
volatile bool _isDisposed
volatile int _operationsOutstanding
volatile CancellationTokenSource _cancellationTokenSource
readonly object _thisLock
void CompleteOperation(bool ownsCancellationTokenSource)
CancellationToken CreateLinkedCancellationToken(CancellationToken cancellationToken)
CloseOutputOperation(WebSocketBase webSocket)
WebSocketCloseStatus CloseStatus
override global::Interop.WebSocket.? Buffer CreateBuffer(ArraySegment< byte >? buffer)
override WebSocketProtocolComponent.ActionQueue ActionQueue
override bool ProcessAction_NoAction()
override void ProcessAction_IndicateReceiveComplete(ArraySegment< byte >? buffer, WebSocketProtocolComponent.BufferType bufferType, WebSocketProtocolComponent.Action action, global::Interop.WebSocket.Buffer[] dataBuffers, uint dataBufferCount, IntPtr actionContext)
override bool ShouldContinue(CancellationToken cancellationToken)
ReceiveOperation(WebSocketBase webSocket)
override void Initialize(ArraySegment< byte >? buffer, CancellationToken cancellationToken)
override WebSocketProtocolComponent.ActionQueue ActionQueue
bool _BufferHasBeenPinned
override bool ShouldContinue(CancellationToken cancellationToken)
SendOperation(WebSocketBase webSocket)
override bool ProcessAction_NoAction()
virtual global::Interop.WebSocket.? Buffer CreateBuffer(ArraySegment< byte >? buffer)
override void Initialize(ArraySegment< byte >? buffer, CancellationToken cancellationToken)
virtual void ProcessAction_IndicateReceiveComplete(ArraySegment< byte >? buffer, WebSocketProtocolComponent.BufferType bufferType, WebSocketProtocolComponent.Action action, global::Interop.WebSocket.Buffer[] dataBuffers, uint dataBufferCount, IntPtr actionContext)
void Initialize(ArraySegment< byte >? buffer, CancellationToken cancellationToken)
readonly WebSocketBase _webSocket
WebSocketOperation(WebSocketBase webSocket)
WebSocketProtocolComponent.ActionQueue ActionQueue
bool AsyncOperationCompleted
bool ProcessAction_NoAction()
WebSocketReceiveResult ReceiveResult
async Task< WebSocketReceiveResult > Process(ArraySegment< byte >? buffer, CancellationToken cancellationToken)
bool ShouldContinue(CancellationToken cancellationToken)
void FinishOnCloseReceived(WebSocketCloseStatus closeStatus, string closeStatusDescription)
void ResetFlagsAndTakeLocks(ref bool thisLockTaken, ref bool sessionHandleLockTaken)
readonly SemaphoreSlim _sendFrameThrottle
volatile WebSocketOperation.ReceiveOperation _receiveOperation
readonly OutstandingOperationHelper _closeOutstandingOperationHelper
volatile Task _closeOutputTask
readonly OutstandingOperationHelper _sendOutstandingOperationHelper
override Task CloseOutputAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
Exception _pendingException
readonly OutstandingOperationHelper _closeOutputOutstandingOperationHelper
async Task CloseOutputAsyncCore(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
static void ReleaseLock(object lockObject, ref bool lockTaken)
void TakeLocks(ref bool thisLockTaken, ref bool sessionHandleLockTaken)
override Task< WebSocketReceiveResult > ReceiveAsync(ArraySegment< byte > buffer, CancellationToken cancellationToken)
static WebSocketProtocolComponent.BufferType GetBufferType(WebSocketMessageType messageType, bool endOfMessage)
volatile Task _closeNetworkConnectionTask
override Task CloseAsync(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
void ThrowIfPendingException()
void FinishOnCloseCompleted()
void EnsureCloseOutputOperation()
WebSocketBuffer InternalBuffer
static async void OnKeepAlive(object sender)
void ValidateNativeBuffers(WebSocketProtocolComponent.Action action, WebSocketProtocolComponent.BufferType bufferType, global::Interop.WebSocket.Buffer[] dataBuffers, uint dataBufferCount)
readonly object _thisLock
void OnBackgroundTaskException(Exception exception)
void ThrowIfConvertibleException(string methodName, Exception exception, CancellationToken cancellationToken, bool aborted)
void StartKeepAliveTimer()
void ReleaseLocks(ref bool thisLockTaken, ref bool sessionHandleLockTaken)
async Task< WebSocketReceiveResult > ReceiveAsyncCore(ArraySegment< byte > buffer, CancellationToken cancellationToken)
void UpdateReceiveState(int newReceiveState, int expectedReceiveState)
readonly WebSocketBuffer _internalBuffer
readonly string _subProtocol
WebSocketBase(Stream innerStream, string subProtocol, TimeSpan keepAliveInterval, WebSocketBuffer internalBuffer)
override string CloseStatusDescription
async Task SendAsyncCore(ArraySegment< byte > buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken)
bool StartOnCloseReceived(ref bool thisLockTaken)
volatile WebSocketOperation.SendOperation _keepAliveOperation
WebSocketCloseStatus? _closeStatus
async Task CloseAsyncCore(WebSocketCloseStatus closeStatus, string statusDescription, CancellationToken cancellationToken)
volatile WebSocketOperation.SendOperation _sendOperation
readonly KeepAliveTracker _keepAliveTracker
override Task SendAsync(ArraySegment< byte > buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken cancellationToken)
void ResetFlagAndTakeLock(object lockObject, ref bool thisLockTaken)
async Task SendFrameAsync(IList< ArraySegment< byte > > sendBuffers, CancellationToken cancellationToken)
bool CanHandleExceptionDuringClose(Exception error)
void EnsureSendOperation()
readonly IWebSocketStream _innerStreamAsWebSocketStream
static WebSocketMessageType GetMessageType(WebSocketProtocolComponent.BufferType bufferType)
volatile bool _isDisposed
string _closeStatusDescription
volatile WebSocketOperation.CloseOutputOperation _closeOutputOperation
void EnsureKeepAliveOperation()
volatile Task _keepAliveTask
override? WebSocketCloseStatus CloseStatus
volatile TaskCompletionSource _closeReceivedTaskCompletionSource
readonly Stream _innerStream
readonly OutstandingOperationHelper _receiveOutstandingOperationHelper
override string SubProtocol
bool OnCloseOutputCompleted()
void ThrowIfAborted(bool aborted, Exception innerException)
async Task< bool > StartOnCloseCompleted(bool thisLockTakenSnapshot, bool sessionHandleLockTakenSnapshot, CancellationToken cancellationToken)
void EnsureReceiveOperation()
volatile WebSocketState _state
override WebSocketState State
volatile bool _closeAsyncStartedReceive
void ValidateNativeBuffers(WebSocketProtocolComponent.Action action, WebSocketProtocolComponent.BufferType bufferType, global::Interop.WebSocket.Buffer[] dataBuffers, uint dataBufferCount)
bool ReceiveFromBufferedPayload(ArraySegment< byte > buffer, out WebSocketReceiveResult receiveResult)
ArraySegment< byte > ConvertPinnedSendPayloadFromNative(global::Interop.WebSocket.Buffer buffer, WebSocketProtocolComponent.BufferType bufferType)
void BufferPayload(ArraySegment< byte > payload, int unconsumedDataOffset, WebSocketMessageType messageType, bool endOfMessage)
bool IsPinnedSendPayloadBuffer(byte[] buffer, int offset, int count)
void ReleasePinnedSendBuffer()
void Dispose(WebSocketState webSocketState)
void ConvertCloseBuffer(WebSocketProtocolComponent.Action action, global::Interop.WebSocket.Buffer buffer, out WebSocketCloseStatus closeStatus, out string reason)
IntPtr ConvertPinnedSendPayloadToNative(ArraySegment< byte > payload)
void PinSendBuffer(ArraySegment< byte > payload, out bool bufferHasBeenPinned)
ArraySegment< byte > ConvertNativeBuffer(WebSocketProtocolComponent.Action action, global::Interop.WebSocket.Buffer buffer, WebSocketProtocolComponent.BufferType bufferType)
static void WebSocketSend(WebSocketBase webSocket, BufferType bufferType, global::Interop.WebSocket.Buffer buffer)
static void WebSocketGetAction(WebSocketBase webSocket, ActionQueue actionQueue, global::Interop.WebSocket.Buffer[] dataBuffers, ref uint dataBufferCount, out Action action, out BufferType bufferType, out IntPtr actionContext)
static void WebSocketAbortHandle(SafeHandle webSocketHandle)
static void WebSocketSendWithoutBody(WebSocketBase webSocket, BufferType bufferType)
static void WebSocketCompleteAction(WebSocketBase webSocket, IntPtr actionContext, int bytesTransferred)
static void WebSocketReceive(WebSocketBase webSocket)
WebSocketCloseStatus? CloseStatus
string? CloseStatusDescription
static void ValidateArraySegment(ArraySegment< byte > arraySegment, string parameterName)
static void ValidateCloseStatus(WebSocketCloseStatus closeStatus, string statusDescription)
static bool IsStateTerminal(WebSocketState state)
static void ThrowOnInvalidState(WebSocketState state, params WebSocketState[] validStates)
static string net_Websockets_AlreadyOneOutstandingOperation
static string net_WebSockets_Argument_InvalidMessageType
static string Format(string resourceFormat, object p1)
static string net_WebSockets_ReceiveAsyncDisallowedAfterCloseAsync
static string net_WebSockets_InvalidMessageType
static string net_WebSockets_InvalidState_ClosedOrAborted
static string net_WebSockets_InvalidBufferType
static CancellationTokenSource CreateLinkedTokenSource(CancellationToken token1, CancellationToken token2)
static int CompareExchange(ref int location1, int value, int comparand)
static int Exchange(ref int location1, int value)
static void Exit(object obj)
static void Enter(object obj)
bool Dispose(WaitHandle notifyObject)
bool Change(int dueTime, int period)
Task MultipleWriteAsync(IList< ArraySegment< byte > > buffers, CancellationToken cancellationToken)
Task CloseNetworkConnectionAsync(CancellationToken cancellationToken)
bool SupportsMultipleWrite
void SwitchToOpaqueMode(WebSocketBase webSocket)
delegate void TimerCallback(object? state)
void ICollection< T >. Add(T item)
static CancellationToken None