1 write to WebSocket
System.Net.WebSockets (1)
System\Net\WebSockets\WebSocketStream.cs (1)
25private WebSocketStream(WebSocket webSocket) => WebSocket = webSocket;
40 references to WebSocket
System.Net.WebSockets (40)
System\Net\WebSockets\WebSocketStream.cs (40)
12/// <summary>Provides a <see cref="Stream"/> that delegates to a wrapped <see cref="WebSocket"/>.</summary> 22/// Initializes a new instance of the <see cref="WebSocketStream"/> class using a specified <see cref="WebSocket"/> instance. 24/// <param name="webSocket">The <see cref="WebSocket"/> wrapped by this instance.</param> 27/// <summary>Creates a <see cref="WebSocketStream"/> that delegates to a wrapped <see cref="WebSocket"/>.</summary> 28/// <param name="webSocket">The wrapped <see cref="WebSocket"/>.</param> 31/// <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"/>. 33/// <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> 45/// <summary>Creates a <see cref="WebSocketStream"/> that delegates to a wrapped <see cref="WebSocket"/>.</summary> 46/// <param name="webSocket">The wrapped <see cref="WebSocket"/>.</param> 48/// <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> 49/// <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> 62/// <summary>Creates a <see cref="WebSocketStream"/> that writes a single message to the underlying <see cref="WebSocket"/>.</summary> 63/// <param name="webSocket">The wrapped <see cref="WebSocket"/>.</param> 66/// Each write on the <see cref="Stream"/> results in writing a partial message to the underlying <see cref="WebSocket"/>. 67/// 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. 69/// <returns>A new instance of <see cref="WebSocketStream"/> that forwards writes on the <see cref="Stream"/> to the underlying <see cref="WebSocket"/>.</returns> 78/// <summary>Creates a <see cref="WebSocketStream"/> that reads a single message from the underlying <see cref="WebSocket"/>.</summary> 79/// <param name="webSocket">The wrapped <see cref="WebSocket"/>.</param> 80/// <returns>A new instance of <see cref="WebSocketStream"/> that forwards reads on the <see cref="Stream"/> to the underlying <see cref="WebSocket"/>.</returns> 82/// Reads on the <see cref="Stream"/> will read a single message from the underlying <see cref="WebSocket"/>. This means that reads will start returning 83/// 0 bytes read once all data has been consumed from the next message received in the <see cref="WebSocket"/>. 92/// <summary>Gets the underlying <see cref="WebSocket"/> wrapped by this <see cref="WebSocketStream"/>.</summary> 93/// <remarks>The <see cref="WebSocket"/> used to construct this instance.</remarks> 97public override bool CanRead => !_disposed && WebSocket.State is WebSocketState.Open or WebSocketState.CloseSent; 100public override bool CanWrite => !_disposed && WebSocket.State is WebSocketState.Open or WebSocketState.CloseReceived; 187/// <summary>Provides stream that wraps a <see cref="WebSocket"/> and forwards reads/writes.</summary> 211return WebSocket.SendAsync(buffer, _messageType, endOfMessage: true, cancellationToken); 226while (WebSocket.State < WebSocketState.CloseReceived) 228ValueWebSocketReceiveResult result = await WebSocket.ReceiveAsync(buffer, cancellationToken).ConfigureAwait(false); 252if (WebSocket.State is < WebSocketState.Closed) 273await WebSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, null, ct).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing); 281WebSocket.Dispose(); 287/// <summary>Provides a stream that wraps a <see cref="WebSocket"/> and writes a single message.</summary> 313return WebSocket.SendAsync(buffer, _messageType, endOfMessage: false, cancellationToken); 321return WebSocket.SendAsync(ReadOnlyMemory<byte>.Empty, _messageType, endOfMessage: true, CancellationToken.None); 328/// <summary>Provides a stream that wraps a <see cref="WebSocket"/> and reads a single message.</summary> 349while (!_eof && WebSocket.State < WebSocketState.CloseReceived) 351ValueWebSocketReceiveResult result = await WebSocket.ReceiveAsync(buffer, cancellationToken).ConfigureAwait(false); 375if (!_eof && WebSocket.State < WebSocketState.CloseReceived) 377WebSocket.Abort();