Interface Session.Server.Listener

All Superinterfaces:
Session.Listener
Enclosing interface:
Session.Server

public static interface Session.Server.Listener extends Session.Listener

The server-side specific Session.Listener.

  • Method Details

    • onAccept

      default void onAccept(Session session)

      Callback method invoked when a connection has been accepted by the server.

      Parameters:
      session - the session
    • onRequest

      default Stream.Server.Listener onRequest(Stream.Server stream, HeadersFrame frame)

      Callback method invoked when a request is received.

      Applications should implement this method to process HTTP/3 requests, typically providing an HTTP/3 response via Stream.Server.respond(HeadersFrame):

       class MyServer implements Session.Server.Listener
       {
           @Override
           public Stream.Server.Listener onRequest(Stream.Server stream, HeadersFrame frame)
           {
               // Send a response.
               var response = new MetaData.Response(HttpVersion.HTTP_3, HttpStatus.OK_200, HttpFields.EMPTY);
               stream.respond(new HeadersFrame(response, true));
               if (!frame.isLast())
                   stream.demand();
               return null;
           }
       }
       

      If there is request content (indicated by the fact that the HEADERS frame is not the last in the stream), then applications either:

      Parameters:
      stream - the stream associated with the request
      frame - the HEADERS frame containing the request headers
      Returns:
      a Stream.Server.Listener that will be notified of stream events
      See Also: