Search in sources :

Example 11 with ChannelBroadcastMessage

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

the class Messages method broadcastMessage.

static ChannelBroadcastMessage broadcastMessage(String channel, Object event) throws Exception {
    final ChannelBroadcastMessage message = new ChannelBroadcastMessage();
    message.setBody(toJson(event));
    message.setChannel(channel);
    return message;
}
Also used : ChannelBroadcastMessage(org.everrest.websockets.message.ChannelBroadcastMessage)

Example 12 with ChannelBroadcastMessage

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

the class BufferOutputFixedRateSender method sendMessage.

private synchronized void sendMessage() {
    final ChannelBroadcastMessage message = new ChannelBroadcastMessage();
    message.setChannel(channel);
    String text = getText();
    if (text.isEmpty()) {
        return;
    }
    message.setBody(text);
    sendMessageToWS(message);
    lines.clear();
}
Also used : ChannelBroadcastMessage(org.everrest.websockets.message.ChannelBroadcastMessage)

Example 13 with ChannelBroadcastMessage

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

the class MavenWebSocketCommunication method send.

@Override
public void send(JsonObject dto, MessageType type) {
    try {
        ChannelBroadcastMessage message = new ChannelBroadcastMessage();
        message.setChannel(MavenAttributes.MAVEN_CHANEL_NAME);
        dto.addProperty("$type", type.getType());
        message.setBody(dto.toString());
        WSConnectionContext.sendMessage(message);
    } catch (EncodeException | IOException e) {
        LOG.error("Can't send maven message:", e);
    }
}
Also used : ChannelBroadcastMessage(org.everrest.websockets.message.ChannelBroadcastMessage) EncodeException(javax.websocket.EncodeException) IOException(java.io.IOException)

Example 14 with ChannelBroadcastMessage

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

the class WebsocketLineConsumer method writeLine.

@Override
public void writeLine(String line) throws IOException {
    final ChannelBroadcastMessage bm = new ChannelBroadcastMessage();
    bm.setChannel(channel);
    bm.setBody(line);
    try {
        WSConnectionContext.sendMessage(bm);
    } catch (Exception e) {
        LOG.error("A problem occurred while sending websocket message", e);
    }
}
Also used : ChannelBroadcastMessage(org.everrest.websockets.message.ChannelBroadcastMessage) IOException(java.io.IOException)

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