1 write to WebSocket
System.Net.WebSockets (1)
System\Net\WebSockets\WebSocketStream.cs (1)
26private WebSocketStream(WebSocket webSocket) => WebSocket = webSocket;
40 references to WebSocket
System.Net.WebSockets (40)
System\Net\WebSockets\WebSocketStream.cs (40)
13/// <summary>Provides a <see cref="Stream"/> that delegates to a wrapped <see cref="WebSocket"/>.</summary> 23/// Initializes a new instance of the <see cref="WebSocketStream"/> class using a specified <see cref="WebSocket"/> instance. 25/// <param name="webSocket">The <see cref="WebSocket"/> wrapped by this instance.</param> 28/// <summary>Creates a <see cref="WebSocketStream"/> that delegates to a wrapped <see cref="WebSocket"/>.</summary> 29/// <param name="webSocket">The wrapped <see cref="WebSocket"/>.</param> 32/// <see langword="true"/> if disposing the <see cref="Stream"/> should close the underlying <see cref="WebSocket"/>; otherwise, <see langword="false"/>. Defaults to <see langword="false"/>. 34/// <returns>A new instance of <see cref="WebSocketStream"/> that forwards reads and writes on the <see cref="Stream"/> to the underlying <see cref="WebSocket"/>.</returns> 46/// <summary>Creates a <see cref="WebSocketStream"/> that delegates to a wrapped <see cref="WebSocket"/>.</summary> 47/// <param name="webSocket">The wrapped <see cref="WebSocket"/>.</param> 49/// <param name="closeTimeout">The amount of time that disposing the <see cref="WebSocketStream"/> will wait for a graceful closing of the <see cref="WebSocket"/>'s output.</param> 50/// <returns>A new instance of <see cref="WebSocketStream"/> that forwards reads and writes on the <see cref="Stream"/> to the underlying <see cref="WebSocket"/>.</returns> 63/// <summary>Creates a <see cref="WebSocketStream"/> that writes a single message to the underlying <see cref="WebSocket"/>.</summary> 64/// <param name="webSocket">The wrapped <see cref="WebSocket"/>.</param> 67/// Each write on the <see cref="Stream"/> results in writing a partial message to the underlying <see cref="WebSocket"/>. 68/// When the <see cref="Stream"/> is disposed, it will write an empty message to the underlying <see cref="WebSocket"/> to signal the end of the message. 70/// <returns>A new instance of <see cref="WebSocketStream"/> that forwards writes on the <see cref="Stream"/> to the underlying <see cref="WebSocket"/>.</returns> 79/// <summary>Creates a <see cref="WebSocketStream"/> that reads a single message from the underlying <see cref="WebSocket"/>.</summary> 80/// <param name="webSocket">The wrapped <see cref="WebSocket"/>.</param> 81/// <returns>A new instance of <see cref="WebSocketStream"/> that forwards reads on the <see cref="Stream"/> to the underlying <see cref="WebSocket"/>.</returns> 83/// Reads on the <see cref="Stream"/> will read a single message from the underlying <see cref="WebSocket"/>. This means that reads will start returning 84/// 0 bytes read once all data has been consumed from the next message received in the <see cref="WebSocket"/>. 93/// <summary>Gets the underlying <see cref="WebSocket"/> wrapped by this <see cref="WebSocketStream"/>.</summary> 94/// <remarks>The <see cref="WebSocket"/> used to construct this instance.</remarks> 98public override bool CanRead => !_disposed && WebSocket.State is WebSocketState.Open or WebSocketState.CloseSent; 101public override bool CanWrite => !_disposed && WebSocket.State is WebSocketState.Open or WebSocketState.CloseReceived; 188/// <summary>Provides stream that wraps a <see cref="WebSocket"/> and forwards reads/writes.</summary> 212return WebSocket.SendAsync(buffer, _messageType, endOfMessage: true, cancellationToken); 227while (WebSocket.State < WebSocketState.CloseReceived) 229ValueWebSocketReceiveResult result = await WebSocket.ReceiveAsync(buffer, cancellationToken).ConfigureAwait(false); 253if (WebSocket.State is < WebSocketState.Closed) 274await WebSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, null, ct).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing); 282WebSocket.Dispose(); 288/// <summary>Provides a stream that wraps a <see cref="WebSocket"/> and writes a single message.</summary> 314return WebSocket.SendAsync(buffer, _messageType, endOfMessage: false, cancellationToken); 322return WebSocket.SendAsync(ReadOnlyMemory<byte>.Empty, _messageType, endOfMessage: true, CancellationToken.None); 329/// <summary>Provides a stream that wraps a <see cref="WebSocket"/> and reads a single message.</summary> 350while (!_eof && WebSocket.State < WebSocketState.CloseReceived) 352ValueWebSocketReceiveResult result = await WebSocket.ReceiveAsync(buffer, cancellationToken).ConfigureAwait(false); 376if (!_eof && WebSocket.State < WebSocketState.CloseReceived) 378WebSocket.Abort();