All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.jetty.spdy.api.SessionFrameListener Maven / Gradle / Ivy

There is a newer version: 11.0.0.beta1
Show newest version
//
//  ========================================================================
//  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
//  ------------------------------------------------------------------------
//  All rights reserved. This program and the accompanying materials
//  are made available under the terms of the Eclipse Public License v1.0
//  and Apache License v2.0 which accompanies this distribution.
//
//      The Eclipse Public License is available at
//      http://www.eclipse.org/legal/epl-v10.html
//
//      The Apache License v2.0 is available at
//      http://www.opensource.org/licenses/apache2.0.php
//
//  You may elect to redistribute this code under either of these licenses.
//  ========================================================================
//

package org.eclipse.jetty.spdy.api;

import java.util.EventListener;

import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;

/**
 * 

A {@link SessionFrameListener} is the passive counterpart of a {@link Session} and receives events happening * on a SPDY session.

* * @see Session */ public interface SessionFrameListener extends EventListener { /** *

Callback invoked when a request to create a stream has been received.

*

Application code should implement this method and reply to the stream creation, eventually * sending data:

*
     * public StreamFrameListener onSyn(Stream stream, SynInfo synInfo)
     * {
     *     // Do something with the metadata contained in synInfo
     *
     *     if (stream.isHalfClosed()) // The other peer will not send data
     *     {
     *         stream.reply(new ReplyInfo(false));
     *         stream.data(new StringDataInfo("foo", true));
     *         return null; // Not interested in further stream events
     *     }
     *
     *     ...
     * }
     * 
*

Alternatively, if the stream creation requires reading data sent from the other peer:

*
     * public StreamFrameListener onSyn(Stream stream, SynInfo synInfo)
     * {
     *     // Do something with the metadata contained in synInfo
     *
     *     if (!stream.isHalfClosed()) // The other peer will send data
     *     {
     *         stream.reply(new ReplyInfo(true));
     *         return new Stream.FrameListener.Adapter() // Interested in stream events
     *         {
     *             public void onData(Stream stream, DataInfo dataInfo)
     *             {
     *                 // Do something with the incoming data in dataInfo
     *             }
     *         };
     *     }
     *
     *     ...
     * }
     * 
* * @param stream the stream just created * @param synInfo the metadata sent on stream creation * @return a listener for stream events, or null if there is no interest in being notified of stream events */ public StreamFrameListener onSyn(Stream stream, SynInfo synInfo); /** *

Callback invoked when a stream error happens.

* * @param session the session * @param rstInfo the metadata of the stream error */ public void onRst(Session session, RstInfo rstInfo); /** *

Callback invoked when a request to configure the SPDY connection has been received.

* * @param session the session * @param settingsInfo the metadata sent to configure */ public void onSettings(Session session, SettingsInfo settingsInfo); /** *

Callback invoked when a ping request has completed its round-trip.

* * @param session the session * @param pingResultInfo the metadata received */ public void onPing(Session session, PingResultInfo pingResultInfo); /** *

Callback invoked when the other peer signals that it is closing the connection.

* * @param session the session * @param goAwayResultInfo the metadata sent */ public void onGoAway(Session session, GoAwayResultInfo goAwayResultInfo); /** *

Callback invoked when an exception is thrown during the processing of an event on a * SPDY session.

*

Examples of such conditions are invalid frames received, corrupted headers compression state, etc.

* * @param x the exception that caused the event processing failure */ public void onException(Throwable x); /** *

Empty implementation of {@link SessionFrameListener}

*/ public static class Adapter implements SessionFrameListener { private static final Logger logger = Log.getLogger(Adapter.class); @Override public StreamFrameListener onSyn(Stream stream, SynInfo synInfo) { return null; } @Override public void onRst(Session session, RstInfo rstInfo) { } @Override public void onSettings(Session session, SettingsInfo settingsInfo) { } @Override public void onPing(Session session, PingResultInfo pingResultInfo) { } @Override public void onGoAway(Session session, GoAwayResultInfo goAwayResultInfo) { } @Override public void onException(Throwable x) { logger.info("", x); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy