UNPKG

sussudio

Version:

An unofficial VS Code Internal API

44 lines (43 loc) 1.93 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { VSBuffer } from "../../../base/common/buffer.mjs"; import { Event } from "../../../base/common/event.mjs"; import { SocketDiagnosticsEventType } from "../../../base/parts/ipc/common/ipc.net.mjs"; import { IConnectCallback, ISocketFactory } from "../common/remoteAgentConnection.mjs"; export interface IWebSocketFactory { create(url: string, debugLabel: string): IWebSocket; } export interface IWebSocketCloseEvent { /** * Returns the WebSocket connection close code provided by the server. */ readonly code: number; /** * Returns the WebSocket connection close reason provided by the server. */ readonly reason: string; /** * Returns true if the connection closed cleanly; false otherwise. */ readonly wasClean: boolean; /** * Underlying event. */ readonly event: any | undefined; } export interface IWebSocket { readonly onData: Event<ArrayBuffer>; readonly onOpen: Event<void>; readonly onClose: Event<IWebSocketCloseEvent | void>; readonly onError: Event<any>; traceSocketEvent?(type: SocketDiagnosticsEventType, data?: VSBuffer | Uint8Array | ArrayBuffer | ArrayBufferView | any): void; send(data: ArrayBuffer | ArrayBufferView): void; close(): void; } export declare class BrowserSocketFactory implements ISocketFactory { private readonly _webSocketFactory; constructor(webSocketFactory: IWebSocketFactory | null | undefined); connect(host: string, port: number, path: string, query: string, debugLabel: string, callback: IConnectCallback): void; }