Class NettyWebSocket

    • Constructor Detail

      • NettyWebSocket

        public NettyWebSocket​(io.netty.channel.Channel channel,
                              io.netty.handler.codec.http.HttpHeaders upgradeHeaders)
    • Method Detail

      • getUpgradeHeaders

        public io.netty.handler.codec.http.HttpHeaders getUpgradeHeaders()
        Specified by:
        getUpgradeHeaders in interface WebSocket
        Returns:
        the headers received in the Upgrade response
      • getRemoteAddress

        public SocketAddress getRemoteAddress()
        Description copied from interface: WebSocket
        Get remote address client initiated request to.
        Specified by:
        getRemoteAddress in interface WebSocket
        Returns:
        remote address client initiated request to, may be null if asynchronous provider is unable to provide the remote address
      • getLocalAddress

        public SocketAddress getLocalAddress()
        Description copied from interface: WebSocket
        Get local address client initiated request from.
        Specified by:
        getLocalAddress in interface WebSocket
        Returns:
        local address client initiated request from, may be null if asynchronous provider is unable to provide the local address
      • sendTextFrame

        public io.netty.util.concurrent.Future<Void> sendTextFrame​(String message)
        Description copied from interface: WebSocket
        Send a full text frame
        Specified by:
        sendTextFrame in interface WebSocket
        Parameters:
        message - a text payload
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendTextFrame

        public io.netty.util.concurrent.Future<Void> sendTextFrame​(String payload,
                                                                   boolean finalFragment,
                                                                   int rsv)
        Description copied from interface: WebSocket
        Allows sending a text frame with fragmentation or extension bits. When using fragmentation, the next fragments must be sent with sendContinuationFrame.
        Specified by:
        sendTextFrame in interface WebSocket
        Parameters:
        payload - a text fragment.
        finalFragment - flag indicating whether this is the final fragment
        rsv - extension bits, 0 otherwise
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendTextFrame

        public io.netty.util.concurrent.Future<Void> sendTextFrame​(io.netty.buffer.ByteBuf payload,
                                                                   boolean finalFragment,
                                                                   int rsv)
        Description copied from interface: WebSocket
        Allows sending a text frame with fragmentation or extension bits. When using fragmentation, the next fragments must be sent with sendContinuationFrame.
        Specified by:
        sendTextFrame in interface WebSocket
        Parameters:
        payload - a ByteBuf fragment.
        finalFragment - flag indicating whether this is the final fragment
        rsv - extension bits, 0 otherwise
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendBinaryFrame

        public io.netty.util.concurrent.Future<Void> sendBinaryFrame​(byte[] payload)
        Description copied from interface: WebSocket
        Send a full binary frame.
        Specified by:
        sendBinaryFrame in interface WebSocket
        Parameters:
        payload - a binary payload
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendBinaryFrame

        public io.netty.util.concurrent.Future<Void> sendBinaryFrame​(byte[] payload,
                                                                     boolean finalFragment,
                                                                     int rsv)
        Description copied from interface: WebSocket
        Allows sending a binary frame with fragmentation or extension bits. When using fragmentation, the next fragments must be sent with sendContinuationFrame.
        Specified by:
        sendBinaryFrame in interface WebSocket
        Parameters:
        payload - a binary payload
        finalFragment - flag indicating whether this is the last fragment
        rsv - extension bits, 0 otherwise
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendBinaryFrame

        public io.netty.util.concurrent.Future<Void> sendBinaryFrame​(io.netty.buffer.ByteBuf payload,
                                                                     boolean finalFragment,
                                                                     int rsv)
        Description copied from interface: WebSocket
        Allows sending a binary frame with fragmentation or extension bits. When using fragmentation, the next fragments must be sent with sendContinuationFrame.
        Specified by:
        sendBinaryFrame in interface WebSocket
        Parameters:
        payload - a ByteBuf payload
        finalFragment - flag indicating whether this is the last fragment
        rsv - extension bits, 0 otherwise
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendContinuationFrame

        public io.netty.util.concurrent.Future<Void> sendContinuationFrame​(String payload,
                                                                           boolean finalFragment,
                                                                           int rsv)
        Description copied from interface: WebSocket
        Send a text continuation frame. The last fragment must have finalFragment set to true.
        Specified by:
        sendContinuationFrame in interface WebSocket
        Parameters:
        payload - the text fragment
        finalFragment - flag indicating whether this is the last fragment
        rsv - extension bits, 0 otherwise
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendContinuationFrame

        public io.netty.util.concurrent.Future<Void> sendContinuationFrame​(byte[] payload,
                                                                           boolean finalFragment,
                                                                           int rsv)
        Description copied from interface: WebSocket
        Send a binary continuation frame. The last fragment must have finalFragment set to true.
        Specified by:
        sendContinuationFrame in interface WebSocket
        Parameters:
        payload - the binary fragment
        finalFragment - flag indicating whether this is the last fragment
        rsv - extension bits, 0 otherwise
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendContinuationFrame

        public io.netty.util.concurrent.Future<Void> sendContinuationFrame​(io.netty.buffer.ByteBuf payload,
                                                                           boolean finalFragment,
                                                                           int rsv)
        Description copied from interface: WebSocket
        Send a continuation frame (those are actually untyped as counterpart must have memorized first fragmented frame type). The last fragment must have finalFragment set to true.
        Specified by:
        sendContinuationFrame in interface WebSocket
        Parameters:
        payload - a ByteBuf fragment
        finalFragment - flag indicating whether this is the last fragment
        rsv - extension bits, 0 otherwise
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendPingFrame

        public io.netty.util.concurrent.Future<Void> sendPingFrame()
        Description copied from interface: WebSocket
        Send an empty ping frame
        Specified by:
        sendPingFrame in interface WebSocket
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendPingFrame

        public io.netty.util.concurrent.Future<Void> sendPingFrame​(byte[] payload)
        Description copied from interface: WebSocket
        Send a ping frame with a byte array payload (limited to 125 bytes or fewer).
        Specified by:
        sendPingFrame in interface WebSocket
        Parameters:
        payload - the payload.
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendPingFrame

        public io.netty.util.concurrent.Future<Void> sendPingFrame​(io.netty.buffer.ByteBuf payload)
        Description copied from interface: WebSocket
        Send a ping frame with a ByteBuf payload (limited to 125 bytes or fewer).
        Specified by:
        sendPingFrame in interface WebSocket
        Parameters:
        payload - the payload.
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendPongFrame

        public io.netty.util.concurrent.Future<Void> sendPongFrame()
        Description copied from interface: WebSocket
        Send an empty pong frame
        Specified by:
        sendPongFrame in interface WebSocket
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendPongFrame

        public io.netty.util.concurrent.Future<Void> sendPongFrame​(byte[] payload)
        Description copied from interface: WebSocket
        Send a pong frame with a byte array payload (limited to 125 bytes or fewer).
        Specified by:
        sendPongFrame in interface WebSocket
        Parameters:
        payload - the payload.
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendPongFrame

        public io.netty.util.concurrent.Future<Void> sendPongFrame​(io.netty.buffer.ByteBuf payload)
        Description copied from interface: WebSocket
        Send a pong frame with a ByteBuf payload (limited to 125 bytes or fewer).
        Specified by:
        sendPongFrame in interface WebSocket
        Parameters:
        payload - the payload.
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendCloseFrame

        public io.netty.util.concurrent.Future<Void> sendCloseFrame()
        Description copied from interface: WebSocket
        Send an empty close frame.
        Specified by:
        sendCloseFrame in interface WebSocket
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendCloseFrame

        public io.netty.util.concurrent.Future<Void> sendCloseFrame​(int statusCode,
                                                                    String reasonText)
        Description copied from interface: WebSocket
        Send an empty close frame.
        Specified by:
        sendCloseFrame in interface WebSocket
        Parameters:
        statusCode - a status code
        reasonText - a reason
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface WebSocket
        Returns:
        true if the WebSocket is open/connected.
      • isReady

        public boolean isReady()
      • bufferFrame

        public void bufferFrame​(io.netty.handler.codec.http.websocketx.WebSocketFrame frame)
      • processBufferedFrames

        public void processBufferedFrames()
      • handleFrame

        public void handleFrame​(io.netty.handler.codec.http.websocketx.WebSocketFrame frame)
      • onError

        public void onError​(Throwable t)
      • onClose

        public void onClose​(int code,
                            String reason)