Class Transport

  • Direct Known Subclasses:
    Polling, WebSocket

    public abstract class Transport
    extends Emitter
    Base class for all transports.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Transport​(Parser parser)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close the transport if not already closed.
      protected abstract void doClose()
      Transport specific logic for closing transport.
      abstract java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getInitialHeaders()
      Get the headers of the initial HTTP request.
      abstract java.util.Map<java.lang.String,​java.lang.String> getInitialQuery()
      Get the query parameters of the initial HTTP request.
      abstract java.lang.String getName()
      Get the name of this transport.
      abstract boolean isWritable()
      Checks whether the transport is currently writable.
      protected void onClose()
      Called by child to indicate closure of transport.
      protected void onData​(java.lang.Object data)
      Called by child to indicate data received from remote client.
      protected void onError​(java.lang.String reason, java.lang.String description)
      Called by child class to indicate error with transport.
      protected void onPacket​(Packet<?> packet)
      Called by child to indicate a packet receive from remote client.
      abstract void onRequest​(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
      Handle a client HTTP request.
      abstract void send​(java.util.List<Packet<?>> packets)
      Send a list of packets over the transport.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • mParser

        protected final Parser mParser
    • Constructor Detail

      • Transport

        protected Transport​(Parser parser)
    • Method Detail

      • getInitialQuery

        public abstract java.util.Map<java.lang.String,​java.lang.String> getInitialQuery()
        Get the query parameters of the initial HTTP request.
        Returns:
        Query parameters of the initial HTTP request.
      • getInitialHeaders

        public abstract java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getInitialHeaders()
        Get the headers of the initial HTTP request.
        Returns:
        Headers of the initial HTTP request.
      • onRequest

        public abstract void onRequest​(jakarta.servlet.http.HttpServletRequest request,
                                       jakarta.servlet.http.HttpServletResponse response)
                                throws java.io.IOException
        Handle a client HTTP request.
        Parameters:
        request - The HTTP request object.
        response - The HTTP response object.
        Throws:
        java.io.IOException - On IO error.
      • send

        public abstract void send​(java.util.List<Packet<?>> packets)
        Send a list of packets over the transport.
        Parameters:
        packets - List of packets to send.
      • isWritable

        public abstract boolean isWritable()
        Checks whether the transport is currently writable.
        Returns:
        Boolean value indicating if transport can be written to.
      • getName

        public abstract java.lang.String getName()
        Get the name of this transport.
        Returns:
        Name of transport.
      • doClose

        protected abstract void doClose()
        Transport specific logic for closing transport.
      • close

        public void close()
        Close the transport if not already closed.
      • onError

        protected void onError​(java.lang.String reason,
                               java.lang.String description)
        Called by child class to indicate error with transport.
        Parameters:
        reason - Reason of error.
        description - Description of error.
      • onPacket

        protected void onPacket​(Packet<?> packet)
        Called by child to indicate a packet receive from remote client.
        Parameters:
        packet - Packet received by transport.
      • onData

        protected void onData​(java.lang.Object data)
        Called by child to indicate data received from remote client.
        Parameters:
        data - Encoded data received by transport.
      • onClose

        protected void onClose()
        Called by child to indicate closure of transport.