Search in sources :

Example 1 with SubscriptionHandler

use of org.eclipse.che.ide.websocket.rest.SubscriptionHandler 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());
            }
        }
    }
}
Also used : SubscriptionHandler(org.eclipse.che.ide.websocket.rest.SubscriptionHandler) MessageHandler(org.eclipse.che.ide.websocket.events.MessageHandler)

Aggregations

MessageHandler (org.eclipse.che.ide.websocket.events.MessageHandler)1 SubscriptionHandler (org.eclipse.che.ide.websocket.rest.SubscriptionHandler)1