Search in sources :

Example 6 with ChannelBroadcastMessage

use of org.everrest.websockets.message.ChannelBroadcastMessage in project che by eclipse.

the class InitializeEventMessenger method send.

protected void send(final LanguageServerInitializeEventDto message) {
    try {
        final ChannelBroadcastMessage bm = new ChannelBroadcastMessage();
        bm.setChannel("languageserver");
        bm.setBody(new Gson().toJson(message));
        WSConnectionContext.sendMessage(bm);
    } catch (EncodeException | IOException e) {
        LOG.error(e.getMessage(), e);
    }
}
Also used : ChannelBroadcastMessage(org.everrest.websockets.message.ChannelBroadcastMessage) Gson(com.google.gson.Gson) EncodeException(javax.websocket.EncodeException) IOException(java.io.IOException)

Example 7 with ChannelBroadcastMessage

use of org.everrest.websockets.message.ChannelBroadcastMessage in project che by eclipse.

the class PublishDiagnosticsParamsMessenger method onEvent.

public void onEvent(final PublishDiagnosticsParams event) {
    try {
        if (event instanceof PublishDiagnosticsParamsImpl && event.getUri().startsWith("file:///projects")) {
            ((PublishDiagnosticsParamsImpl) event).setUri(event.getUri().substring(16));
        }
        final ChannelBroadcastMessage bm = new ChannelBroadcastMessage();
        bm.setChannel("languageserver/textDocument/publishDiagnostics");
        bm.setBody(new Gson().toJson(event));
        WSConnectionContext.sendMessage(bm);
    } catch (EncodeException | IOException e) {
        LOG.error(e.getMessage(), e);
    }
}
Also used : ChannelBroadcastMessage(org.everrest.websockets.message.ChannelBroadcastMessage) Gson(com.google.gson.Gson) EncodeException(javax.websocket.EncodeException) PublishDiagnosticsParamsImpl(io.typefox.lsapi.impl.PublishDiagnosticsParamsImpl) IOException(java.io.IOException)

Example 8 with ChannelBroadcastMessage

use of org.everrest.websockets.message.ChannelBroadcastMessage in project che by eclipse.

the class VfsWatchBroadcaster method onEvent.

@Override
public void onEvent(VfsWatchEvent event) {
    try {
        final ChannelBroadcastMessage bm = new ChannelBroadcastMessage();
        bm.setChannel(VfsWatchEvent.VFS_CHANNEL);
        bm.setBody(DtoFactory.getInstance().toJson(event));
        WSConnectionContext.sendMessage(bm);
    } catch (Exception e) {
        LOG.error(e.getLocalizedMessage(), e);
    }
}
Also used : ChannelBroadcastMessage(org.everrest.websockets.message.ChannelBroadcastMessage)

Example 9 with ChannelBroadcastMessage

use of org.everrest.websockets.message.ChannelBroadcastMessage in project che by eclipse.

the class ShowMessageMessenger method onEvent.

public void onEvent(final MessageParams event) {
    try {
        final ChannelBroadcastMessage bm = new ChannelBroadcastMessage();
        bm.setChannel("languageserver/window/showMessage");
        bm.setBody(new Gson().toJson(event));
        WSConnectionContext.sendMessage(bm);
    } catch (EncodeException | IOException e) {
        LOG.error(e.getMessage(), e);
    }
}
Also used : ChannelBroadcastMessage(org.everrest.websockets.message.ChannelBroadcastMessage) Gson(com.google.gson.Gson) EncodeException(javax.websocket.EncodeException) IOException(java.io.IOException)

Example 10 with ChannelBroadcastMessage

use of org.everrest.websockets.message.ChannelBroadcastMessage in project che by eclipse.

the class ProjectImportOutputWSLineConsumer method sendMessage.

protected void sendMessage(String line) {
    final ChannelBroadcastMessage bm = new ChannelBroadcastMessage();
    bm.setChannel("importProject:output");
    JsonObject json = new JsonObject();
    json.addProperty("num", lineCounter.getAndIncrement());
    json.addProperty("line", line);
    json.addProperty("project", projectName);
    bm.setBody(json.toString());
    sendMessageToWS(bm);
}
Also used : ChannelBroadcastMessage(org.everrest.websockets.message.ChannelBroadcastMessage) JsonObject(com.google.gson.JsonObject)

Aggregations

ChannelBroadcastMessage (org.everrest.websockets.message.ChannelBroadcastMessage)14 IOException (java.io.IOException)5 EncodeException (javax.websocket.EncodeException)4 Gson (com.google.gson.Gson)3 JsonObject (com.google.gson.JsonObject)1 PublishDiagnosticsParamsImpl (io.typefox.lsapi.impl.PublishDiagnosticsParamsImpl)1