mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 09:35:37 -05:00
Add connection event listeners (#6540)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ export abstract class ExtHostAccountManagementShape {
|
||||
}
|
||||
|
||||
export abstract class ExtHostConnectionManagementShape {
|
||||
$onConnectionOpened(handleId: string, connection: azdata.connection.Connection): void { throw ni; }
|
||||
$onConnectionEvent(handle: number, type: azdata.connection.ConnectionEventType, ownerUri: string, profile: azdata.IConnectionProfile): void { throw ni(); }
|
||||
}
|
||||
|
||||
export abstract class ExtHostDataProtocolShape {
|
||||
@@ -606,6 +606,7 @@ export interface MainThreadDataProtocolShape extends IDisposable {
|
||||
}
|
||||
|
||||
export interface MainThreadConnectionManagementShape extends IDisposable {
|
||||
$registerConnectionEventListener(handle: number, providerId: string): void;
|
||||
$getConnections(activeConnectionsOnly?: boolean): Thenable<azdata.connection.ConnectionProfile[]>;
|
||||
$getActiveConnections(): Thenable<azdata.connection.Connection[]>;
|
||||
$getCurrentConnection(): Thenable<azdata.connection.Connection>;
|
||||
|
||||
Reference in New Issue
Block a user