Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Not only messages from client to server but rather mesages messages from server client might be needed.

Messages that can be send from server to client are defined in the KeithLanguageClient:

Code Block
titleExample KeithLanguageLCient
 * LanguageClient that implements additional methods necessary for server client communication in KEITH.
 * @author really fancy name
interface KeithLanguageClient extends LanguageClient {
    def void compile(Object results, String uri, boolean finished);
    def void cancelCompilation(boolean success);
	// Not only notifications, but also server client requests should be possible, but currently there is no use case for that.

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

The method should receive all parameters specific in the KeithLanguageClient interface on the serevr side.

Such a notification from server to client is send like this:

Code Block
	// 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)

Register and calling an extension (on client side)