Search in sources :

Example 1 with ReplyHandler

use of org.eclipse.che.ide.websocket.events.ReplyHandler in project che by eclipse.

the class AbstractMessageBus method onMessageReceived.

/** {@inheritDoc} */
@Override
public void onMessageReceived(MessageReceivedEvent event) {
    Message message = parseMessage(event.getMessage());
    // as it might be disallowed when processing actually takes place.
    if (message.getResponseCode() == 202) {
        return;
    }
    //TODO Should be revised to remove
    List<Pair> headers = message.getHeaders().toList();
    if (headers != null) {
        for (Pair header : headers) {
            if (HTTPHeader.LOCATION.equals(header.getName()) && header.getValue().contains("async/")) {
                return;
            }
        }
    }
    if (getChannel(message) != null) {
        // this is a message received by subscription
        processSubscriptionMessage(message);
    } else {
        String uuid = message.getStringField(MessageBuilder.UUID_FIELD);
        ReplyHandler replyCallback = replyCallbackMap.remove(uuid);
        if (replyCallback != null) {
            replyCallback.onReply(message.getBody());
        } else {
            RequestCallback requestCallback = requestCallbackMap.remove(uuid);
            if (requestCallback != null) {
                requestCallback.onReply(message);
            }
        }
    }
}
Also used : ReplyHandler(org.eclipse.che.ide.websocket.events.ReplyHandler) RequestCallback(org.eclipse.che.ide.websocket.rest.RequestCallback) Pair(org.eclipse.che.ide.websocket.rest.Pair)

Aggregations

ReplyHandler (org.eclipse.che.ide.websocket.events.ReplyHandler)1 Pair (org.eclipse.che.ide.websocket.rest.Pair)1 RequestCallback (org.eclipse.che.ide.websocket.rest.RequestCallback)1