Show / Hide Table of Contents

Class StreamDemuxer

The StreamDemuxer allows you to interact with processes running in a container in a Kubernetes pod. You can start an exec or attach command by calling WebSocketNamespacedPodExecAsync(string, string, IEnumerable<string>, string, bool, bool, bool, bool, string, Dictionary<string, List<string>>, CancellationToken) or WebSocketNamespacedPodAttachAsync(string, string, string, bool, bool, bool, bool, string, Dictionary<string, List<string>>, CancellationToken). These methods will return you a WebSocket connection.

Kubernetes 'multiplexes' multiple channels over this WebSocket connection, such as standard input, standard output and standard error. The StreamDemuxer allows you to extract individual Streams from this WebSocket. You can then use these streams to send/receive data from that process.

Inheritance
object
StreamDemuxer
Implements
IStreamDemuxer
IDisposable
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: k8s
Assembly: KubernetesClient.dll
Syntax
public class StreamDemuxer : IStreamDemuxer, IDisposable

Constructors

StreamDemuxer(WebSocket, StreamType, bool, bool)

Initializes a new instance of the StreamDemuxer class.

Declaration
public StreamDemuxer(WebSocket webSocket, StreamType streamType = StreamType.RemoteCommand, bool ownsSocket = false, bool supportsClose = false)
Parameters
Type Name Description
WebSocket webSocket

A WebSocket which contains a multiplexed stream, such as the WebSocket returned by the exec or attach commands.

StreamType streamType

A StreamType specifies the type of the stream.

bool ownsSocket

A value indicating whether this instance of the StreamDemuxer owns the underlying WebSocket, and should dispose of it when this instance is disposed of.

bool supportsClose

A value indicating whether the v5 streaming protocol is in use, which supports closing individual channels (e.g. stdin) via a dedicated close message.

Properties

SupportsClose

Gets a value indicating whether this demuxer supports closing individual channels via the v5 streaming protocol. When true, disposing a writable MuxedStream will send a close message to the server for that channel.

Declaration
public bool SupportsClose { get; }
Property Value
Type Description
bool

Methods

CloseChannel(byte, CancellationToken)

Sends a v5 close message for the specified channel, signalling that the client will no longer write to that channel (e.g. EOF on stdin).

Declaration
public Task CloseChannel(byte index, CancellationToken cancellationToken = default)
Parameters
Type Name Description
byte index

The index of the channel to close.

CancellationToken cancellationToken

A CancellationToken which can be used to cancel the asynchronous operation.

Returns
Type Description
Task

A Task which represents the asynchronous operation.

CloseChannel(ChannelIndex, CancellationToken)

Sends a v5 close message for the specified channel, signalling that the client will no longer write to that channel (e.g. EOF on stdin).

Declaration
public Task CloseChannel(ChannelIndex index, CancellationToken cancellationToken = default)
Parameters
Type Name Description
ChannelIndex index

The ChannelIndex of the channel to close.

CancellationToken cancellationToken

A CancellationToken which can be used to cancel the asynchronous operation.

Returns
Type Description
Task

A Task which represents the asynchronous operation.

Dispose()

Declaration
public void Dispose()

Dispose(bool)

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

GetStream(byte?, byte?)

Gets a Stream which allows you to read to and/or write from a remote channel.

Declaration
public Stream GetStream(byte? inputIndex, byte? outputIndex)
Parameters
Type Name Description
byte? inputIndex

The index of the channel from which to read.

byte? outputIndex

The index of the channel to which to write.

Returns
Type Description
Stream

A Stream which allows you to read/write to the requested channels.

GetStream(ChannelIndex?, ChannelIndex?)

Gets a Stream which allows you to read to and/or write from a remote channel.

Declaration
public Stream GetStream(ChannelIndex? inputIndex, ChannelIndex? outputIndex)
Parameters
Type Name Description
ChannelIndex? inputIndex

The index of the channel from which to read.

ChannelIndex? outputIndex

The index of the channel to which to write.

Returns
Type Description
Stream

A Stream which allows you to read/write to the requested channels.

RunLoop(CancellationToken)

Declaration
protected Task RunLoop(CancellationToken cancellationToken)
Parameters
Type Name Description
CancellationToken cancellationToken
Returns
Type Description
Task

Start()

Starts reading the data sent by the server.

Declaration
public void Start()

Write(byte, byte[], int, int, CancellationToken)

Directly writes data to a channel.

Declaration
public Task Write(byte index, byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)
Parameters
Type Name Description
byte index

The index of the channel to which to write.

byte[] buffer

The buffer from which to read data.

int offset

The offset at which to start reading.

int count

The number of bytes to read.

CancellationToken cancellationToken

A CancellationToken which can be used to cancel the asynchronous operation.

Returns
Type Description
Task

A Task which represents the asynchronous operation.

Write(ChannelIndex, byte[], int, int, CancellationToken)

Directly writes data to a channel.

Declaration
public Task Write(ChannelIndex index, byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)
Parameters
Type Name Description
ChannelIndex index

The index of the channel to which to write.

byte[] buffer

The buffer from which to read data.

int offset

The offset at which to start reading.

int count

The number of bytes to read.

CancellationToken cancellationToken

A CancellationToken which can be used to cancel the asynchronous operation.

Returns
Type Description
Task

A Task which represents the asynchronous operation.

Events

ConnectionClosed

Declaration
public event EventHandler ConnectionClosed
Event Type
Type Description
EventHandler

Implements

IStreamDemuxer
IDisposable
In this article
Back to top Generated by DocFX