Page History
...
These messages can be caught on the client side by defining the message that is caught like this:
Code Block | ||
---|---|---|
| ||
export const snapshotDescriptionMessageType = new NotificationType<CodeContainer, void>('keith/kicool/compile'); |
This message type is bound to a method that should be called whenever the client receives such a message.
Code Block | ||
---|---|---|
| ||
const lClient: ILanguageClient = await this.client.languageClient lClient.onNotification(snapshotDescriptionMessageType, this.handleNewSnapshotDescriptions.bind(this)) |
...
Such a notification from server to client is send like this:
Code Block | ||
---|---|---|
| ||
future.thenAccept([ // client is the KeithLanguageClient registered in a LanguageServerExtension that implements a ILanguageClientProvider // compile is the command defined in the KeithLanguageClientInterface client.compile(new CompilationResults(this.snapshotMap.get(uri)), uri, finished) ]) |
...
You can send a request or a notification to the language server like this:
Code Block | ||
---|---|---|
| ||
const lclient = await this.client.languageClient const snapshotsDescriptions: CodeContainer = await lclient.sendRequest("keith/kicool/compile", [uri, KeithDiagramManager.DIAGRAM_TYPE + '_sprotty', command, this.compilerWidget.compileInplace]) as CodeContainer // or via a thenable client.languageClient.then(lClient => { lClient.sendRequest("keith/kicool/compile").then((snapshotsDescriptions: CodeContainer) => { // very important stuff } // await is preferred, since it is shorter. |
In this example client is an instance of a language client. It is usually injected like this:
Code Block | ||
---|---|---|
| ||
@inject(KeithLanguageClientContribution) public readonly client: KeithLanguageClientContribution constructor( // other injected classes that are relevant for the constructor ) { // constructor stuff } |
...
Overview
Content Tools