@sussudio/platform
Version:
Internal APIs for VS Code's service injection the base services.
55 lines (53 loc) • 1.88 kB
text/typescript
/*---------------------------------------------------------------------------------------------
* 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 '@sussudio/base/common/buffer.mjs';
import { Event } from '@sussudio/base/common/event.mjs';
import { SocketDiagnosticsEventType } from '@sussudio/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;
}