Class OmniSharpPlatformChannel
- Namespace
- RDCore.SDK.Client.Connection
- Assembly
- RDCore.SDK.dll
The IRDCorePlatformChannel of an OmniSharp language client: what rdc.exe and every RDCoreClientApp speak the platform's
protocol through, so that they run the same client logic (RDCorePlatformClient) as a client that has only RDCore.SDK.Protocol.
public sealed class OmniSharpPlatformChannel : IRDCorePlatformChannel
- Inheritance
-
OmniSharpPlatformChannel
- Implements
- Inherited Members
Remarks
An IDE whose language client is OmniSharp's, and which starts the language server itself (RDCoreLanguageServerLaunch), speaks the platform
handshake over its own connection with this channel: new RDCorePlatformClient(new OmniSharpPlatformChannel(client)), once initialize is
answered.
The JSON is handed to OmniSharp as written by Options, and handed back as OmniSharp read it: Newtonsoft only carries it, so the wire is the Protocol package's, whatever OmniSharp's serializer would have made of the types.
A string that looks like an ISO 8601 date and time (19 to 40 characters, a digit first, a T at the eleventh) is written as it is, but is not always
read as it was: OmniSharp parses every incoming message with a reader of its own that takes such a string for a date, whatever its serializer says, and
writes it back as the date it read. One with an offset, a Z or a fraction of a second then arrives otherwise ("…12:34:56+02:00" in the offset of the
machine, "….000Z" without its fraction); one without, as VBA's Format writes them, arrives as it was. A channel that does not read through OmniSharp
has no such change.
Constructors
OmniSharpPlatformChannel(ILanguageClient, ILogger?, string?, Task?)
The IRDCorePlatformChannel of an OmniSharp language client: what rdc.exe and every RDCoreClientApp speak the platform's
protocol through, so that they run the same client logic (RDCorePlatformClient) as a client that has only RDCore.SDK.Protocol.
public OmniSharpPlatformChannel(ILanguageClient client, ILogger? logger = null, string? peer = null, Task? lost = null)
Parameters
clientILanguageClientThe language client, connected.
loggerILoggerLogs each request and how it ended.
peerstringWhat the client is connected to, as the log names it.
lostTaskCompletes when the process the client is connected to exits: a request it has not answered by then fails with a ServerProtocolSdkException. null for a client whose peer is not a process of its own.
Remarks
An IDE whose language client is OmniSharp's, and which starts the language server itself (RDCoreLanguageServerLaunch), speaks the platform
handshake over its own connection with this channel: new RDCorePlatformClient(new OmniSharpPlatformChannel(client)), once initialize is
answered.
The JSON is handed to OmniSharp as written by Options, and handed back as OmniSharp read it: Newtonsoft only carries it, so the wire is the Protocol package's, whatever OmniSharp's serializer would have made of the types.
A string that looks like an ISO 8601 date and time (19 to 40 characters, a digit first, a T at the eleventh) is written as it is, but is not always
read as it was: OmniSharp parses every incoming message with a reader of its own that takes such a string for a date, whatever its serializer says, and
writes it back as the date it read. One with an offset, a Z or a fraction of a second then arrives otherwise ("…12:34:56+02:00" in the offset of the
machine, "….000Z" without its fraction); one without, as VBA's Format writes them, arrives as it was. A channel that does not read through OmniSharp
has no such change.
Methods
OnNotification(string, Func<JsonElement?, CancellationToken, Task>)
Handles the notifications of a method the server sends the client, until the returned registration is disposed.
public IDisposable OnNotification(string method, Func<JsonElement?, CancellationToken, Task> handler)
Parameters
methodstringThe JSON-RPC method.
handlerFunc<JsonElement?, CancellationToken, Task>Handles a notification, given its
params(null when it has none).
Returns
- IDisposable
The registration; disposing it stops handling the method.
Remarks
A method has one handler at a time: another is registered once the registration of the first is disposed.
Exceptions
- InvalidOperationException
The method is already answered or handled on this channel.
OnRequest(string, Func<JsonElement?, CancellationToken, Task<JsonElement?>>)
Answers the requests of a method the server sends the client, until the returned registration is disposed.
public IDisposable OnRequest(string method, Func<JsonElement?, CancellationToken, Task<JsonElement?>> handler)
Parameters
methodstringThe JSON-RPC method.
handlerFunc<JsonElement?, CancellationToken, Task<JsonElement?>>Answers a request: given its
params(null when it has none), returns itsresult.
Returns
- IDisposable
The registration; disposing it stops answering the method.
Remarks
A method has one handler at a time: another is registered once the registration of the first is disposed.
Exceptions
- InvalidOperationException
The method is already answered or handled on this channel.
SendNotificationAsync(string, JsonElement?, CancellationToken)
Sends a notification to the server.
public Task SendNotificationAsync(string method, JsonElement? parameters, CancellationToken token)
Parameters
methodstringThe JSON-RPC method.
parametersJsonElement?The
paramsof the notification; null to send none.tokenCancellationTokenCancels before the notification is sent.
Returns
SendRequestAsync(string, JsonElement?, CancellationToken)
Sends a request to the server and returns its result.
public Task<JsonElement?> SendRequestAsync(string method, JsonElement? parameters, CancellationToken token)
Parameters
methodstringThe JSON-RPC method: one of RDCorePlatformProtocol.
parametersJsonElement?The
paramsof the request; null to send none.tokenCancellationTokenCancels the request.
Returns
- Task<JsonElement?>
The
resultof the response; null when it is JSONnull.