Class EngineIoSocket


  • public final class EngineIoSocket
    extends Emitter
    An engine.io socket. Objects of this class represents connections to remote clients one per object.
    • Field Detail

      • PAYLOAD_NOOP

        private static final java.util.List<Packet<?>> PAYLOAD_NOOP
      • EMPTY_UPGRADES

        private static final java.lang.String EMPTY_UPGRADES
      • WEBSOCKET_UPGRADES

        private static final java.lang.String WEBSOCKET_UPGRADES
      • mSid

        private final java.lang.String mSid
      • mProtocolVersion

        private final int mProtocolVersion
      • mWriteBuffer

        private final java.util.LinkedList<Packet<?>> mWriteBuffer
      • mCallbacks

        private final java.util.concurrent.ConcurrentHashMap<java.lang.String,​java.util.concurrent.ConcurrentLinkedQueue<EngineIoSocket.SocketedListener>> mCallbacks
      • mLockObject

        private final java.lang.Object mLockObject
      • mScheduledTaskHandler

        private final java.util.concurrent.ScheduledExecutorService mScheduledTaskHandler
      • mPingTask

        private final java.lang.Runnable mPingTask
      • mPingTimeoutTask

        private final java.lang.Runnable mPingTimeoutTask
      • mPingFuture

        private java.util.concurrent.ScheduledFuture<?> mPingFuture
      • mPingTimeoutFuture

        private java.util.concurrent.ScheduledFuture<?> mPingTimeoutFuture
      • mUpgrading

        private final java.util.concurrent.atomic.AtomicBoolean mUpgrading
      • mCleanupFunction

        private java.lang.Runnable mCleanupFunction
      • mInitialQuery

        private java.util.Map<java.lang.String,​java.lang.String> mInitialQuery
      • mInitialHeaders

        private java.util.Map<java.lang.String,​java.util.List<java.lang.String>> mInitialHeaders
    • Constructor Detail

      • EngineIoSocket

        EngineIoSocket​(java.lang.Object lockObject,
                       java.lang.String sid,
                       int protocolVersion,
                       EngineIoServer server,
                       java.util.concurrent.ScheduledExecutorService scheduledTaskHandler)
    • Method Detail

      • getId

        public java.lang.String getId()
        Gets the sid of this socket.
      • getProtocolVersion

        public int getProtocolVersion()
        Gets the protocol version of this socket.
      • getReadyState

        public ReadyState getReadyState()
        Gets the ready state of this socket.
      • getInitialQuery

        public java.util.Map<java.lang.String,​java.lang.String> getInitialQuery()
        Get the query parameters of the initial HTTP connection.
      • getInitialHeaders

        public java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getInitialHeaders()
        Get the headers of the initial HTTP connection.
      • send

        public void send​(Packet<?> packet)
        Send a packet to the remote client. Queuing of packets in case of polling transport are handled internally. This method is thread safe.
        Parameters:
        packet - The packet to send.
      • close

        public void close()
        Close this socket.
      • on

        public EngineIoSocket on​(java.lang.String event,
                                 EngineIoSocket.SocketedListener fn)
        Listen on the event. NOTE: Unstable api. Might change in the future.
        Parameters:
        event - Event name
        fn - Event listener
        Returns:
        A reference to this object
      • off

        public EngineIoSocket off​(java.lang.String event,
                                  EngineIoSocket.SocketedListener fn)
        Removes the listener. NOTE: Unstable api. Might change in the future.
        Parameters:
        event - an event name.
        fn - Event listener.
        Returns:
        a reference to this object.
      • off

        public EngineIoSocket off​(java.lang.String event)
        Description copied from class: Emitter
        Removes all listeners of the specified event.
        Overrides:
        off in class Emitter
        Parameters:
        event - an event name.
        Returns:
        a reference to this object.
      • emit

        public Emitter emit​(java.lang.String event,
                            java.lang.Object... args)
        Description copied from class: Emitter
        Executes each of listeners with the given args.
        Overrides:
        emit in class Emitter
        Parameters:
        event - an event name.
        args - Data to emit.
        Returns:
        a reference to this object.
      • init

        void init​(Transport transport)
        Called after instance creation to initialize transport.
        Parameters:
        transport - The opened transport.
      • updateInitialHeadersFromActiveTransport

        void updateInitialHeadersFromActiveTransport()
      • onRequest

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

        boolean canUpgrade​(java.lang.String transport)
        Checks whether the socket can be upgraded to another transport.
        Parameters:
        transport - The transport to upgrade to.
        Returns:
        Boolean value indicating if upgrade is possible.
      • upgrade

        void upgrade​(Transport transport)
        Perform upgrade to the specified transport.
        Parameters:
        transport - The transport to upgrade to.
      • getCurrentTransportName

        java.lang.String getCurrentTransportName()
        Get the name of the current transport.
        Returns:
        Name of current transport.
      • setTransport

        private void setTransport​(Transport transport)
      • closeTransport

        private void closeTransport()
      • clearTransport

        private void clearTransport()
      • onOpen

        private void onOpen()
      • onClose

        private void onClose​(java.lang.String reason,
                             java.lang.String description)
      • onError

        private void onError()
      • onPacket

        private void onPacket​(Packet<?> packet)
      • sendPacket

        private void sendPacket​(Packet<?> packet)
      • flush

        private void flush()
      • sendPing

        private void sendPing()
      • schedulePing

        private void schedulePing()
      • resetPingTimeout

        private void resetPingTimeout​(long timeout)