Add connection event listeners (#6540)

This commit is contained in:
Karl Burtram
2019-07-31 11:52:58 -07:00
committed by GitHub
parent 2c79d49487
commit bc4b527de0
5 changed files with 78 additions and 2 deletions

View File

@@ -10,6 +10,8 @@ import * as azdata from 'azdata';
export class ExtHostConnectionManagement extends ExtHostConnectionManagementShape {
private _proxy: MainThreadConnectionManagementShape;
private _nextListenerHandle: number = 0;
private _connectionListeners = new Map<number, azdata.connection.ConnectionEventListener>();
constructor(
mainContext: IMainContext
@@ -22,6 +24,19 @@ export class ExtHostConnectionManagement extends ExtHostConnectionManagementShap
return this._proxy.$getCurrentConnectionProfile();
}
public $onConnectionEvent(handle: number, type: azdata.connection.ConnectionEventType, ownerUri: string, profile: azdata.IConnectionProfile): void {
let listener = this._connectionListeners[handle];
if (listener) {
listener.onConnectionEvent(type, ownerUri, profile);
}
}
public $registerConnectionEventListener(providerId: string, listener: azdata.connection.ConnectionEventListener): void {
this._connectionListeners[this._nextListenerHandle] = listener;
this._proxy.$registerConnectionEventListener(this._nextListenerHandle, providerId);
this._nextListenerHandle++;
}
public $getConnections(activeConnectionsOnly?: boolean): Thenable<azdata.connection.ConnectionProfile[]> {
return this._proxy.$getConnections(activeConnectionsOnly);
}