UNPKG

3.12 kBTypeScriptView Raw
1import { ILogger } from '../common/logger';
2import { Event, Emitter } from '../common/event';
3import { DefaultFrontendApplicationContribution } from './frontend-application';
4import { StatusBar } from './status-bar/status-bar';
5import { WebSocketConnectionProvider } from './messaging/ws-connection-provider';
6import { Disposable, DisposableCollection } from '../common';
7/**
8 * Service for listening on backend connection changes.
9 */
10export declare const ConnectionStatusService: unique symbol;
11export interface ConnectionStatusService {
12 /**
13 * The actual connection status.
14 */
15 readonly currentStatus: ConnectionStatus;
16 /**
17 * Clients can listen on connection status change events.
18 */
19 readonly onStatusChange: Event<ConnectionStatus>;
20}
21/**
22 * The connection status.
23 */
24export declare enum ConnectionStatus {
25 /**
26 * Connected to the backend.
27 */
28 ONLINE = 0,
29 /**
30 * The connection is lost between frontend and backend.
31 */
32 OFFLINE = 1
33}
34export declare class ConnectionStatusOptions {
35 static DEFAULT: ConnectionStatusOptions;
36 /**
37 * Timeout in milliseconds before the application is considered offline. Must be a positive integer.
38 */
39 readonly offlineTimeout: number;
40}
41export declare const PingService: unique symbol;
42export interface PingService {
43 ping(): Promise<void>;
44}
45export declare abstract class AbstractConnectionStatusService implements ConnectionStatusService, Disposable {
46 protected readonly options: ConnectionStatusOptions;
47 protected readonly statusChangeEmitter: Emitter<ConnectionStatus>;
48 protected connectionStatus: ConnectionStatus;
49 protected logger: ILogger;
50 constructor(options?: ConnectionStatusOptions);
51 get onStatusChange(): Event<ConnectionStatus>;
52 get currentStatus(): ConnectionStatus;
53 dispose(): void;
54 protected updateStatus(success: boolean): void;
55 protected fireStatusChange(status: ConnectionStatus): void;
56}
57export declare class FrontendConnectionStatusService extends AbstractConnectionStatusService {
58 private scheduledPing;
59 protected readonly wsConnectionProvider: WebSocketConnectionProvider;
60 protected readonly pingService: PingService;
61 protected init(): void;
62 protected schedulePing(): void;
63 protected performPingRequest(): Promise<void>;
64 protected setTimeout(handler: (...args: any[]) => void, timeout: number): number;
65 protected clearTimeout(handle?: number): void;
66}
67export declare class ApplicationConnectionStatusContribution extends DefaultFrontendApplicationContribution {
68 protected readonly connectionStatusService: ConnectionStatusService;
69 protected readonly statusBar: StatusBar;
70 protected readonly logger: ILogger;
71 protected readonly toDisposeOnOnline: DisposableCollection;
72 constructor(connectionStatusService: ConnectionStatusService, statusBar: StatusBar, logger: ILogger);
73 protected onStateChange(state: ConnectionStatus): void;
74 private statusbarId;
75 protected handleOnline(): void;
76 protected handleOffline(): void;
77}
78//# sourceMappingURL=connection-status-service.d.ts.map
\No newline at end of file