Show / Hide Table of Contents

# Class ChannelBase

Defines a base implementation for servers and their clients over a single kind of communication channel.

##### Inheritance

System.Object
ChannelBase
StdioClientChannel
StdioServerChannel

##### Inherited Members

System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()

###### Namespace:Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Channel

###### Assembly:Microsoft.SqlTools.ServiceLayer.dll

##### Syntax

    public abstract class ChannelBase

### Properties

| Improve this Doc View Source

#### IsConnected

Gets a boolean that is true if the channel is connected or false if not.

##### Declaration

    public bool IsConnected { get; protected set; }

##### Property Value

Type | Description
--- | ---
System.Boolean |

| Improve this Doc View Source

#### MessageReader

Gets the MessageReader for reading messages from the channel.

##### Declaration

    public MessageReader MessageReader { get; protected set; }

##### Property Value

Type | Description
--- | ---
MessageReader |

| Improve this Doc View Source

#### MessageWriter

Gets the MessageWriter for writing messages to the channel.

##### Declaration

    public MessageWriter MessageWriter { get; protected set; }

##### Property Value

Type | Description
--- | ---
MessageWriter |

### Methods

| Improve this Doc View Source

#### Initialize(IMessageSerializer)

A method to be implemented by subclasses to handle the actual initialization of the channel and the creation and assignment of the MessageReader and MessageWriter properties.

##### Declaration

    protected abstract void Initialize(IMessageSerializer messageSerializer)

##### Parameters

Type | Name | Description
--- | --- | ---
IMessageSerializer | messageSerializer | The IMessageSerializer to use for message serialization.

| Improve this Doc View Source

#### Shutdown()

A method to be implemented by subclasses to handle shutdown of the channel once Stop is called.

##### Declaration

    protected abstract void Shutdown()

| Improve this Doc View Source

#### Start(MessageProtocolType)

Starts the channel and initializes the MessageDispatcher.

##### Declaration

    public void Start(MessageProtocolType messageProtocolType)

##### Parameters

Type | Name | Description
--- | --- | ---
MessageProtocolType | messageProtocolType | The type of message protocol used by the channel.

| Improve this Doc View Source

#### Stop()

Stops the channel.

##### Declaration

    public void Stop()

| Improve this Doc View Source

#### WaitForConnection()

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.

##### Declaration

    public abstract Task WaitForConnection()

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task | A Task to be awaited until a connection is made.