Disconnect session (#764)

This commit is contained in:
Alan Ren
2019-01-16 22:03:18 -08:00
committed by GitHub
parent 5f6d500977
commit 7cc2636e6a
2 changed files with 56 additions and 1 deletions

View File

@@ -115,6 +115,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
this.ServiceHost.SetRequestHandler(StopProfilingRequest.Type, HandleStopProfilingRequest);
this.ServiceHost.SetRequestHandler(PauseProfilingRequest.Type, HandlePauseProfilingRequest);
this.ServiceHost.SetRequestHandler(GetXEventSessionsRequest.Type, HandleGetXEventSessionsRequest);
this.ServiceHost.SetRequestHandler(DisconnectSessionRequest.Type, HandleDisconnectSessionRequest);
this.SessionMonitor.AddSessionListener(this);
}
@@ -147,7 +148,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
else
{
IXEventSession xeSession = null;
// first check whether the session with the given name already exists.
// if so skip the creation part. An exception will be thrown if no session with given name can be found,
// and it can be ignored.
@@ -314,6 +315,25 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
});
}
/// <summary>
/// Handle request to disconnect a session
/// </summary>
internal async Task HandleDisconnectSessionRequest(DisconnectSessionParams parameters, RequestContext<DisconnectSessionResult> requestContext)
{
await Task.Run(async () =>
{
try
{
ProfilerSession session;
monitor.StopMonitoringSession(parameters.OwnerUri, out session);
}
catch (Exception e)
{
await requestContext.SendError(e);
}
});
}
/// <summary>
/// Gets a list of all running XEvent Sessions
/// </summary>