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

View Source

StreamDemuxer(WebSocket, StreamType, bool)

Initializes a new instance of the StreamDemuxer class.

Declaration
public StreamDemuxer(WebSocket webSocket, StreamType streamType = StreamType.RemoteCommand, bool ownsSocket = 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.

Methods

View Source

Dispose()

Declaration
public void Dispose()
View Source

Dispose(bool)

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

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.

View Source

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.

View Source

RunLoop(CancellationToken)

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

Start()

Starts reading the data sent by the server.

Declaration
public void Start()
View Source

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.

View Source

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

View Source

ConnectionClosed

Declaration
public event EventHandler ConnectionClosed
Event Type
Type Description
EventHandler

Implements

IStreamDemuxer
IDisposable
  • View Source
In this article
Back to top Generated by DocFX