mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-17 02:51:45 -05:00
Disconnect session (#764)
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
|
||||||
|
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||||
|
using Microsoft.SqlTools.Utility;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.Profiler.Contracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Disconnect Session request parameters
|
||||||
|
/// </summary>
|
||||||
|
public class DisconnectSessionParams : GeneralRequestDetails
|
||||||
|
{
|
||||||
|
public string OwnerUri { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DisconnectSessionResult { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disconnect session request type
|
||||||
|
/// </summary>
|
||||||
|
public class DisconnectSessionRequest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Request definition
|
||||||
|
/// </summary>
|
||||||
|
public static readonly
|
||||||
|
RequestType<DisconnectSessionParams, DisconnectSessionResult> Type =
|
||||||
|
RequestType<DisconnectSessionParams, DisconnectSessionResult>.Create("profiler/disconnect");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -115,6 +115,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
|
|||||||
this.ServiceHost.SetRequestHandler(StopProfilingRequest.Type, HandleStopProfilingRequest);
|
this.ServiceHost.SetRequestHandler(StopProfilingRequest.Type, HandleStopProfilingRequest);
|
||||||
this.ServiceHost.SetRequestHandler(PauseProfilingRequest.Type, HandlePauseProfilingRequest);
|
this.ServiceHost.SetRequestHandler(PauseProfilingRequest.Type, HandlePauseProfilingRequest);
|
||||||
this.ServiceHost.SetRequestHandler(GetXEventSessionsRequest.Type, HandleGetXEventSessionsRequest);
|
this.ServiceHost.SetRequestHandler(GetXEventSessionsRequest.Type, HandleGetXEventSessionsRequest);
|
||||||
|
this.ServiceHost.SetRequestHandler(DisconnectSessionRequest.Type, HandleDisconnectSessionRequest);
|
||||||
|
|
||||||
this.SessionMonitor.AddSessionListener(this);
|
this.SessionMonitor.AddSessionListener(this);
|
||||||
}
|
}
|
||||||
@@ -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>
|
/// <summary>
|
||||||
/// Gets a list of all running XEvent Sessions
|
/// Gets a list of all running XEvent Sessions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user