mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-21 09:35:39 -05:00
Initial commit of SqlTools Service API
This commit is contained in:
44
ServiceHost/Client/LanguageClientBase.cs
Normal file
44
ServiceHost/Client/LanguageClientBase.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Microsoft.PowerShell.EditorServices.Protocol.LanguageServer;
|
||||
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
|
||||
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.Channel;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Protocol.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a base implementation for language server clients.
|
||||
/// </summary>
|
||||
public abstract class LanguageClientBase : ProtocolEndpoint
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes an instance of the language client using the
|
||||
/// specified channel for communication.
|
||||
/// </summary>
|
||||
/// <param name="clientChannel">The channel to use for communication with the server.</param>
|
||||
public LanguageClientBase(ChannelBase clientChannel)
|
||||
: base(clientChannel, MessageProtocolType.LanguageServer)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Task OnStart()
|
||||
{
|
||||
// Initialize the implementation class
|
||||
return this.Initialize();
|
||||
}
|
||||
|
||||
protected override async Task OnStop()
|
||||
{
|
||||
// First, notify the language server that we're stopping
|
||||
var response = await this.SendRequest(ShutdownRequest.Type, new object());
|
||||
await this.SendEvent(ExitNotification.Type, new object());
|
||||
}
|
||||
|
||||
protected abstract Task Initialize();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user