import WebSocket = require('isomorphic-ws'); import stream = require('stream'); import { V1Status } from './api'; import { KubeConfig } from './config'; export type TextHandler = (text: string) => boolean; export type BinaryHandler = (stream: number, buff: Buffer) => boolean; export interface WebSocketInterface { connect(path: string, textHandler: TextHandler | null, binaryHandler: BinaryHandler | null): Promise; } export interface StreamInterface { stdin: stream.Readable; stdout: stream.Writable; stderr: stream.Writable; } export declare class WebSocketHandler implements WebSocketInterface { readonly config: KubeConfig; readonly socketFactory?: ((uri: string, protocols: string[], opts: WebSocket.ClientOptions) => WebSocket.WebSocket) | undefined; readonly streams: StreamInterface; static readonly StdinStream: number; static readonly StdoutStream: number; static readonly StderrStream: number; static readonly StatusStream: number; static readonly ResizeStream: number; static readonly CloseStream: number; static supportsClose(protocol: string): boolean; static closeStream(streamNum: number, streams: StreamInterface): void; static handleStandardStreams(streamNum: number, buff: Buffer, stdout: stream.Writable | null, stderr: stream.Writable | null): V1Status | null; static handleStandardInput(ws: WebSocket.WebSocket, stdin: stream.Readable | any, streamNum?: number): boolean; static processData(data: string | Buffer, ws: WebSocket.WebSocket | null, createWS: () => Promise, streamNum?: number, retryCount?: number): Promise; static restartableHandleStandardInput(createWS: () => Promise, stdin: stream.Readable | any, streamNum?: number, retryCount?: number): () => WebSocket.WebSocket | null; constructor(config: KubeConfig, socketFactory?: ((uri: string, protocols: string[], opts: WebSocket.ClientOptions) => WebSocket.WebSocket) | undefined, streams?: StreamInterface); /** * Connect to a web socket endpoint. * @param path The HTTP Path to connect to on the server. * @param textHandler Callback for text over the web socket. * Returns true if the connection should be kept alive, false to disconnect. * @param binaryHandler Callback for binary data over the web socket. * Returns true if the connection should be kept alive, false to disconnect. */ connect(path: string, textHandler: ((text: string) => boolean) | null, binaryHandler: ((stream: number, buff: Buffer) => boolean) | null): Promise; }