import { binary, errors, url } from '@synnaxlabs/x'; import { z } from 'zod'; import { MiddlewareCollector } from './middleware'; import { Stream, StreamClient } from './stream'; export type WebsocketMessage
= {
type: "data" | "close" | "open";
error?: errors.Payload;
payload?: P;
};
/**
* WebSocketClient is an implementation of StreamClient that is backed by websockets.
*/
export declare class WebSocketClient extends MiddlewareCollector implements StreamClient {
baseUrl: url.URL;
encoder: binary.Codec;
secure: boolean;
static readonly MESSAGE_TYPE = "arraybuffer";
/**
* @param encoder - The encoder to use for encoding messages and decoding responses.
* @param baseEndpoint - A base url to use as a prefix for all requests.
*/
constructor(baseEndpoint: url.URL, encoder: binary.Codec, secure?: boolean);
withCodec(codec: binary.Codec): WebSocketClient;
/** Implements the StreamClient interface. */
stream