de.mklinger.qetcher.client.jetty.http2.ISession Maven / Gradle / Ivy
Show all versions of qetcher-client-bundle Show documentation
//
// ========================================================================
// Copyright (c) 1995-2018 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.http2;
import java.io.IOException;
import org.eclipse.jetty.http2.api.Session;
import org.eclipse.jetty.http2.api.Stream;
import org.eclipse.jetty.http2.frames.DataFrame;
import org.eclipse.jetty.http2.frames.Frame;
import org.eclipse.jetty.http2.frames.PushPromiseFrame;
import org.eclipse.jetty.http2.frames.WindowUpdateFrame;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.Promise;
/**
* The SPI interface for implementing a HTTP/2 session.
* This class extends {@link Session} by adding the methods required to
* implement the HTTP/2 session functionalities.
*/
public interface ISession extends Session
{
@Override
public IStream getStream(int streamId);
/**
* Removes the given {@code stream}.
*
* @param stream the stream to remove
*/
public void removeStream(IStream stream);
/**
* Enqueues the given frames to be written to the connection.
*
* @param stream the stream the frames belong to
* @param callback the callback that gets notified when the frames have been sent
* @param frame the first frame to enqueue
* @param frames additional frames to enqueue
*/
public void frames(IStream stream, Callback callback, Frame frame, Frame... frames);
/**
* Enqueues the given PUSH_PROMISE frame to be written to the connection.
* Differently from {@link #frames(IStream, Callback, Frame, Frame...)}, this method
* generates atomically the stream id for the pushed stream.
*
* @param stream the stream associated to the pushed stream
* @param promise the promise that gets notified of the pushed stream creation
* @param frame the PUSH_PROMISE frame to enqueue
* @param listener the listener that gets notified of pushed stream events
*/
public void push(IStream stream, Promise promise, PushPromiseFrame frame, Stream.Listener listener);
/**
* Enqueues the given DATA frame to be written to the connection.
*
* @param stream the stream the data frame belongs to
* @param callback the callback that gets notified when the frame has been sent
* @param frame the DATA frame to send
*/
public void data(IStream stream, Callback callback, DataFrame frame);
/**
* Updates the session send window by the given {@code delta}.
*
* @param delta the delta value (positive or negative) to add to the session send window
* @return the previous value of the session send window
*/
public int updateSendWindow(int delta);
/**
* Updates the session receive window by the given {@code delta}.
*
* @param delta the delta value (positive or negative) to add to the session receive window
* @return the previous value of the session receive window
*/
public int updateRecvWindow(int delta);
/**
* Callback method invoked when a WINDOW_UPDATE frame has been received.
*
* @param stream the stream the window update belongs to, or null if the window update belongs to the session
* @param frame the WINDOW_UPDATE frame received
*/
public void onWindowUpdate(IStream stream, WindowUpdateFrame frame);
/**
* @return whether the push functionality is enabled
*/
public boolean isPushEnabled();
/**
* Callback invoked when the connection reads -1.
*
* @see #onIdleTimeout()
* @see #close(int, String, Callback)
*/
public void onShutdown();
/**
* Callback invoked when the idle timeout expires.
*
* @see #onShutdown()
* @see #close(int, String, Callback)
* @return {@code true} if the session has expired
*/
public boolean onIdleTimeout();
/**
* Callback method invoked during an HTTP/1.1 to HTTP/2 upgrade requests
* to process the given synthetic frame.
*
* @param frame the synthetic frame to process
*/
public void onFrame(Frame frame);
/**
* Callback method invoked when bytes are flushed to the network.
*
* @param bytes the number of bytes flushed to the network
* @throws IOException if the flush should fail
*/
public void onFlushed(long bytes) throws IOException;
/**
* @return the number of bytes written by this session
*/
public long getBytesWritten();
/**
* Callback method invoked when a DATA frame is received.
*
* @param frame the DATA frame received
* @param callback the callback to notify when the frame has been processed
*/
public void onData(DataFrame frame, Callback callback);
}