Show / Hide Table of Contents

# Class ProtocolEndpoint

Provides behavior for a client or server endpoint that communicates using the specified protocol.

##### Inheritance

System.Object
ProtocolEndpoint
ServiceHostBase

##### 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

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

##### Syntax

    public class ProtocolEndpoint : IProtocolEndpoint, IMessageSender

### Constructors

| Improve this Doc View Source

#### ProtocolEndpoint(ChannelBase, MessageProtocolType)

Initializes an instance of the protocol server using the specified channel for communication.

##### Declaration

    public ProtocolEndpoint(ChannelBase protocolChannel, MessageProtocolType messageProtocolType)

##### Parameters

Type | Name | Description
--- | --- | ---
ChannelBase | protocolChannel | The channel to use for communication with the connected endpoint.
MessageProtocolType | messageProtocolType | The type of message protocol used by the endpoint.

### Properties

| Improve this Doc View Source

#### MessageDispatcher

Gets the MessageDispatcher which allows registration of handlers for requests, responses, and events that are transmitted through the channel.

##### Declaration

    protected MessageDispatcher MessageDispatcher { get; set; }

##### Property Value

Type | Description
--- | ---
MessageDispatcher |

### Methods

| Improve this Doc View Source

#### OnConnect()

##### Declaration

    protected virtual Task OnConnect()

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task |

| Improve this Doc View Source

#### OnStart()

##### Declaration

    protected virtual Task OnStart()

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task |

| Improve this Doc View Source

#### OnStop()

##### Declaration

    protected virtual Task OnStop()

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task |

| Improve this Doc View Source

#### SendEvent<TParams>(EventType<TParams>, TParams)

Sends an event to the channel's endpoint.

##### Declaration

    public Task SendEvent<TParams>(EventType<TParams> eventType, TParams eventParams)

##### Parameters

Type | Name | Description
--- | --- | ---
EventType<TParams> | eventType | The type of event being sent.
TParams | eventParams | The event parameters being sent.

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task | A Task that tracks completion of the send operation.

##### Type Parameters

Name | Description
--- | ---
TParams | The event parameter type.

##### Implements

IMessageSender.SendEvent<TParams>(EventType<TParams>, TParams)
| Improve this Doc View Source

#### SendRequest<TParams, TResult>(RequestType<TParams, TResult>, TParams)

Sends a request to the server

##### Declaration

    public Task<TResult> SendRequest<TParams, TResult>(RequestType<TParams, TResult> requestType, TParams requestParams)

##### Parameters

Type | Name | Description
--- | --- | ---
RequestType<TParams, TResult> | requestType |
TParams | requestParams |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<TResult> |

##### Type Parameters

Name | Description
--- | ---
TParams |
TResult |

| Improve this Doc View Source

#### SendRequest<TParams, TResult>(RequestType<TParams, TResult>, TParams, Boolean)

##### Declaration

    public Task<TResult> SendRequest<TParams, TResult>(RequestType<TParams, TResult> requestType, TParams requestParams, bool waitForResponse)

##### Parameters

Type | Name | Description
--- | --- | ---
RequestType<TParams, TResult> | requestType |
TParams | requestParams |
System.Boolean | waitForResponse |

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task<TResult> |

##### Type Parameters

Name | Description
--- | ---
TParams |
TResult |

##### Implements

IMessageSender.SendRequest<TParams, TResult>(RequestType<TParams, TResult>, TParams, Boolean)
| Improve this Doc View Source

#### SetEventHandler<TParams>(EventType<TParams>, Func<TParams, EventContext, Task>)

##### Declaration

    public void SetEventHandler<TParams>(EventType<TParams> eventType, Func<TParams, EventContext, Task> eventHandler)

##### Parameters

Type | Name | Description
--- | --- | ---
EventType<TParams> | eventType |
System.Func<TParams, EventContext, System.Threading.Tasks.Task> | eventHandler |

##### Type Parameters

Name | Description
--- | ---
TParams |

##### Implements

IProtocolEndpoint.SetEventHandler<TParams>(EventType<TParams>, Func<TParams, EventContext, Task>)
| Improve this Doc View Source

#### SetEventHandler<TParams>(EventType<TParams>, Func<TParams, EventContext, Task>, Boolean)

##### Declaration

    public void SetEventHandler<TParams>(EventType<TParams> eventType, Func<TParams, EventContext, Task> eventHandler, bool overrideExisting)

##### Parameters

Type | Name | Description
--- | --- | ---
EventType<TParams> | eventType |
System.Func<TParams, EventContext, System.Threading.Tasks.Task> | eventHandler |
System.Boolean | overrideExisting |

##### Type Parameters

Name | Description
--- | ---
TParams |

##### Implements

IProtocolEndpoint.SetEventHandler<TParams>(EventType<TParams>, Func<TParams, EventContext, Task>, Boolean)
| Improve this Doc View Source

#### SetRequestHandler<TParams, TResult>(RequestType<TParams, TResult>, Func<TParams, RequestContext<TResult>, Task>)

##### Declaration

    public void SetRequestHandler<TParams, TResult>(RequestType<TParams, TResult> requestType, Func<TParams, RequestContext<TResult>, Task> requestHandler)

##### Parameters

Type | Name | Description
--- | --- | ---
RequestType<TParams, TResult> | requestType |
System.Func<TParams, RequestContext<TResult>, System.Threading.Tasks.Task> | requestHandler |

##### Type Parameters

Name | Description
--- | ---
TParams |
TResult |

##### Implements

IProtocolEndpoint.SetRequestHandler<TParams, TResult>(RequestType<TParams, TResult>, Func<TParams, RequestContext<TResult>, Task>)
| Improve this Doc View Source

#### Start()

Starts the language server client and sends the Initialize method.

##### Declaration

    public Task Start()

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task | A Task that can be awaited for initialization to complete.

| Improve this Doc View Source

#### Stop()

##### Declaration

    public Task Stop()

##### Returns

Type | Description
--- | ---
System.Threading.Tasks.Task |

| Improve this Doc View Source

#### WaitForExit()

##### Declaration

    public void WaitForExit()