Search in sources :

Example 1 with Type

use of org.apache.qpid.proton.engine.Event.Type in project vertx-proton by vert-x3.

the class ProtonTransport method handleSocketBuffer.

private void handleSocketBuffer(Buffer buff) {
    pumpInbound(buff);
    if (!failed) {
        processSaslAuthentication();
    }
    Event protonEvent = null;
    while ((protonEvent = collector.peek()) != null) {
        ProtonConnectionImpl conn = (ProtonConnectionImpl) protonEvent.getConnection().getContext();
        Type eventType = protonEvent.getType();
        if (LOG.isTraceEnabled() && !eventType.equals(Type.TRANSPORT)) {
            LOG.trace("New Proton Event: " + eventType);
        }
        switch(eventType) {
            case CONNECTION_REMOTE_OPEN:
                {
                    conn.fireRemoteOpen();
                    initiateIdleTimeoutChecks();
                    break;
                }
            case CONNECTION_REMOTE_CLOSE:
                {
                    conn.fireRemoteClose();
                    break;
                }
            case SESSION_REMOTE_OPEN:
                {
                    ProtonSessionImpl session = (ProtonSessionImpl) protonEvent.getSession().getContext();
                    if (session == null) {
                        conn.fireRemoteSessionOpen(protonEvent.getSession());
                    } else {
                        session.fireRemoteOpen();
                    }
                    break;
                }
            case SESSION_REMOTE_CLOSE:
                {
                    ProtonSessionImpl session = (ProtonSessionImpl) protonEvent.getSession().getContext();
                    session.fireRemoteClose();
                    break;
                }
            case LINK_REMOTE_OPEN:
                {
                    ProtonLinkImpl<?> link = (ProtonLinkImpl<?>) protonEvent.getLink().getContext();
                    if (link == null) {
                        conn.fireRemoteLinkOpen(protonEvent.getLink());
                    } else {
                        link.fireRemoteOpen();
                    }
                    break;
                }
            case LINK_REMOTE_DETACH:
                {
                    ProtonLinkImpl<?> link = (ProtonLinkImpl<?>) protonEvent.getLink().getContext();
                    link.fireRemoteDetach();
                    break;
                }
            case LINK_REMOTE_CLOSE:
                {
                    ProtonLinkImpl<?> link = (ProtonLinkImpl<?>) protonEvent.getLink().getContext();
                    link.fireRemoteClose();
                    break;
                }
            case LINK_FLOW:
                {
                    ProtonLinkImpl<?> link = (ProtonLinkImpl<?>) protonEvent.getLink().getContext();
                    link.handleLinkFlow();
                    break;
                }
            case DELIVERY:
                {
                    ProtonDeliveryImpl delivery = (ProtonDeliveryImpl) protonEvent.getDelivery().getContext();
                    if (delivery != null) {
                        delivery.fireUpdate();
                    } else {
                        ProtonReceiverImpl receiver = (ProtonReceiverImpl) protonEvent.getLink().getContext();
                        receiver.onDelivery();
                    }
                    break;
                }
            case TRANSPORT_ERROR:
                {
                    failed = true;
                    break;
                }
            case CONNECTION_INIT:
            case CONNECTION_BOUND:
            case CONNECTION_UNBOUND:
            case CONNECTION_LOCAL_OPEN:
            case CONNECTION_LOCAL_CLOSE:
            case CONNECTION_FINAL:
            case SESSION_INIT:
            case SESSION_LOCAL_OPEN:
            case SESSION_LOCAL_CLOSE:
            case SESSION_FINAL:
            case LINK_INIT:
            case LINK_LOCAL_OPEN:
            case LINK_LOCAL_DETACH:
            case LINK_LOCAL_CLOSE:
            case LINK_FINAL:
        }
        collector.pop();
    }
    flush();
    if (failed) {
        disconnect();
    }
}
Also used : Type(org.apache.qpid.proton.engine.Event.Type) Event(org.apache.qpid.proton.engine.Event)

Aggregations

Event (org.apache.qpid.proton.engine.Event)1 Type (org.apache.qpid.proton.engine.Event.Type)1