Skip to content

WebSocketTextWriter

A TextWriter that sends UTF-8 text frames over a WebSocket. Synchronous Write(string) calls are buffered and sent on FlushAsync().

public sealed class WebSocketTextWriter : TextWriter, IAsyncDisposable, IDisposable

WebSocketTextWriter(WebSocket, CancellationToken)

Section titled “WebSocketTextWriter(WebSocket, CancellationToken)”

A TextWriter that sends UTF-8 text frames over a WebSocket. Synchronous Write(string) calls are buffered and sent on FlushAsync().

public WebSocketTextWriter(WebSocket socket, CancellationToken cancellationToken)

Asynchronously clears all buffers for the current writer and causes any buffered data to be written to the underlying device.

public override Task FlushAsync()

Task - A task that represents the asynchronous flush operation.

Writes a character to the text stream.

public override void Write(char value)
  • value (char): The character to write to the text stream.

Writes a string to the text stream.

public override void Write(string? value)
  • value (string): The string to write.

Writes a string to the text stream asynchronously.

public override Task WriteAsync(string? value)
  • value (string): The string to write. If value is null, nothing is written to the text stream.

Task - A task that represents the asynchronous write operation.

Writes a string to the text stream, followed by a line terminator.

public override void WriteLine(string? value)
  • value (string): The string to write. If value is null, only the line terminator is written.

Asynchronously writes a string to the text stream, followed by a line terminator.

public override Task WriteLineAsync(string? value)
  • value (string): The string to write. If the value is null, only a line terminator is written.

Task - A task that represents the asynchronous write operation.

When overridden in a derived class, returns the character encoding in which the output is written.

public override Encoding Encoding { get; }

Encoding - The character encoding in which the output is written.