use of org.eclipse.che.ide.websocket.events.MessageHandler in project che by eclipse.
the class AbstractMessageBus method processSubscriptionMessage.
/**
* Process the {@link Message} that received by subscription.
*
* @param message
* {@link Message}
*/
private void processSubscriptionMessage(Message message) {
String channel = getChannel(message);
List<MessageHandler> subscribersSet = channelToSubscribersMap.get(channel);
if (subscribersSet != null) {
for (MessageHandler handler : subscribersSet) {
//TODO this is nasty, need refactor this
if (handler instanceof SubscriptionHandler) {
((SubscriptionHandler) handler).onMessage(message);
} else {
handler.onMessage(message.getBody());
}
}
}
}
use of org.eclipse.che.ide.websocket.events.MessageHandler in project che by eclipse.
the class ResolvingMavenProjectStateHolder method onWsAgentStarted.
@Override
public void onWsAgentStarted(WsAgentStateEvent event) {
wsAgentStateController.getMessageBus().then(new Operation<MessageBus>() {
@Override
public void apply(MessageBus messageBus) throws OperationException {
try {
messageBus.subscribe(MAVEN_CHANEL_NAME, new MessageHandler() {
@Override
public void onMessage(String message) {
Jso jso = Jso.deserialize(message);
int type = jso.getFieldCastedToInteger("$type");
MessageType messageType = MessageType.valueOf(type);
if (messageType == START_STOP) {
handleStartStop(factory.createDtoFromJson(message, StartStopNotification.class));
}
}
});
} catch (WebSocketException e) {
Log.error(getClass(), e);
}
}
});
}
Aggregations