// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. // using System.Threading.Tasks; using Microsoft.SqlTools.Hosting.Protocol; namespace Microsoft.SqlTools.Hosting.Channels { /// /// Defines a base implementation for servers and their clients over a /// single kind of communication channel. /// public abstract class ChannelBase { #region Properties /// /// Gets a boolean that is true if the channel is connected or false if not. /// public bool IsConnected { get; protected internal set; } /// /// Gets the MessageReader for reading messages from the channel. /// public MessageReader MessageReader { get; protected internal set; } /// /// Gets the MessageWriter for writing messages to the channel. /// public MessageWriter MessageWriter { get; protected internal set; } #endregion #region Abstract Methods /// /// Starts the channel and initializes the MessageDispatcher. /// public abstract void Start(); /// /// Stops the channel. /// public abstract void Stop(); /// /// Returns a Task that allows the consumer of the ChannelBase /// implementation to wait until a connection has been made to /// the opposite endpoint whether it's a client or server. /// /// A Task to be awaited until a connection is made. public abstract Task WaitForConnection(); #endregion } }