Merge from vscode 8b5ebbb1b8f6b2127bbbd551ac10cc080482d5b4 (#5041)

This commit is contained in:
Anthony Dresser
2019-04-15 20:37:22 -07:00
committed by GitHub
parent dcdbc95ae7
commit a5bc65fbfb
48 changed files with 495 additions and 294 deletions

View File

@@ -7,6 +7,7 @@ import { Client, PersistentProtocol, ISocket } from 'vs/base/parts/ipc/common/ip
import { generateUuid } from 'vs/base/common/uuid';
import { RemoteAgentConnectionContext } from 'vs/platform/remote/common/remoteAgentEnvironment';
import { Disposable } from 'vs/base/common/lifecycle';
import { Emitter } from 'vs/base/common/event';
export const enum ConnectionType {
Management = 1,
@@ -147,8 +148,38 @@ export async function connectRemoteAgentTunnel(options: IConnectionOptions, tunn
return protocol;
}
export const enum PersistenConnectionEventType {
ConnectionLost,
ReconnectionWait,
ReconnectionRunning,
ReconnectionPermanentFailure,
ConnectionGain
}
export class ConnectionLostEvent {
public readonly type = PersistenConnectionEventType.ConnectionLost;
}
export class ReconnectionWaitEvent {
public readonly type = PersistenConnectionEventType.ReconnectionWait;
constructor(
public readonly durationSeconds: number
) { }
}
export class ReconnectionRunningEvent {
public readonly type = PersistenConnectionEventType.ReconnectionRunning;
}
export class ConnectionGainEvent {
public readonly type = PersistenConnectionEventType.ConnectionGain;
}
export class ReconnectionPermanentFailureEvent {
public readonly type = PersistenConnectionEventType.ReconnectionPermanentFailure;
}
export type PersistenConnectionEvent = ConnectionLostEvent | ReconnectionWaitEvent | ReconnectionRunningEvent | ConnectionGainEvent | ReconnectionPermanentFailureEvent;
abstract class PersistentConnection extends Disposable {
private readonly _onDidStateChange = this._register(new Emitter<PersistenConnectionEvent>());
public readonly onDidStateChange = this._onDidStateChange.event;
protected readonly _options: IConnectionOptions;
public readonly reconnectionToken: string;
public readonly protocol: PersistentProtocol;