Interface WebSocket

  • All Known Implementing Classes:
    NettyWebSocket

    public interface WebSocket
    A WebSocket client
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      WebSocket addWebSocketListener​(WebSocketListener l)
      SocketAddress getLocalAddress()
      Get local address client initiated request from.
      SocketAddress getRemoteAddress()
      Get remote address client initiated request to.
      io.netty.handler.codec.http.HttpHeaders getUpgradeHeaders()  
      boolean isOpen()  
      WebSocket removeWebSocketListener​(WebSocketListener l)
      io.netty.util.concurrent.Future<Void> sendBinaryFrame​(byte[] payload)
      Send a full binary frame.
      io.netty.util.concurrent.Future<Void> sendBinaryFrame​(byte[] payload, boolean finalFragment, int rsv)
      Allows sending a binary frame with fragmentation or extension bits.
      io.netty.util.concurrent.Future<Void> sendBinaryFrame​(io.netty.buffer.ByteBuf payload, boolean finalFragment, int rsv)
      Allows sending a binary frame with fragmentation or extension bits.
      io.netty.util.concurrent.Future<Void> sendCloseFrame()
      Send a empty close frame.
      io.netty.util.concurrent.Future<Void> sendCloseFrame​(int statusCode, String reasonText)
      Send a empty close frame.
      io.netty.util.concurrent.Future<Void> sendContinuationFrame​(byte[] payload, boolean finalFragment, int rsv)
      Send a binary continuation frame.
      io.netty.util.concurrent.Future<Void> sendContinuationFrame​(io.netty.buffer.ByteBuf payload, boolean finalFragment, int rsv)
      Send a continuation frame (those are actually untyped as counterpart must have memorized first fragmented frame type).
      io.netty.util.concurrent.Future<Void> sendContinuationFrame​(String payload, boolean finalFragment, int rsv)
      Send a text continuation frame.
      io.netty.util.concurrent.Future<Void> sendPingFrame()
      Send a empty ping frame
      io.netty.util.concurrent.Future<Void> sendPingFrame​(byte[] payload)
      Send a ping frame with a byte array payload (limited to 125 bytes or less).
      io.netty.util.concurrent.Future<Void> sendPingFrame​(io.netty.buffer.ByteBuf payload)
      Send a ping frame with a ByteBuf payload (limited to 125 bytes or less).
      io.netty.util.concurrent.Future<Void> sendPongFrame()
      Send a empty pong frame
      io.netty.util.concurrent.Future<Void> sendPongFrame​(byte[] payload)
      Send a pong frame with a byte array payload (limited to 125 bytes or less).
      io.netty.util.concurrent.Future<Void> sendPongFrame​(io.netty.buffer.ByteBuf payload)
      Send a pong frame with a ByteBuf payload (limited to 125 bytes or less).
      io.netty.util.concurrent.Future<Void> sendTextFrame​(io.netty.buffer.ByteBuf payload, boolean finalFragment, int rsv)
      Allows sending a text frame with fragmentation or extension bits.
      io.netty.util.concurrent.Future<Void> sendTextFrame​(String payload)
      Send a full text frame
      io.netty.util.concurrent.Future<Void> sendTextFrame​(String payload, boolean finalFragment, int rsv)
      Allows sending a text frame with fragmentation or extension bits.
    • Method Detail

      • getUpgradeHeaders

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

        SocketAddress getRemoteAddress()
        Get remote address client initiated request to.
        Returns:
        remote address client initiated request to, may be null if asynchronous provider is unable to provide the remote address
      • getLocalAddress

        SocketAddress getLocalAddress()
        Get local address client initiated request from.
        Returns:
        local address client initiated request from, may be null if asynchronous provider is unable to provide the local address
      • sendTextFrame

        io.netty.util.concurrent.Future<Void> sendTextFrame​(String payload)
        Send a full text frame
        Parameters:
        payload - a text payload
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendTextFrame

        io.netty.util.concurrent.Future<Void> sendTextFrame​(String payload,
                                                            boolean finalFragment,
                                                            int rsv)
        Allows sending a text frame with fragmentation or extension bits. When using fragmentation, the next fragments must be sent with sendContinuationFrame.
        Parameters:
        payload - a text fragment.
        finalFragment - flag indicating whether or not 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

        io.netty.util.concurrent.Future<Void> sendTextFrame​(io.netty.buffer.ByteBuf payload,
                                                            boolean finalFragment,
                                                            int rsv)
        Allows sending a text frame with fragmentation or extension bits. When using fragmentation, the next fragments must be sent with sendContinuationFrame.
        Parameters:
        payload - a ByteBuf fragment.
        finalFragment - flag indicating whether or not 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

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

        io.netty.util.concurrent.Future<Void> sendBinaryFrame​(byte[] payload,
                                                              boolean finalFragment,
                                                              int rsv)
        Allows sending a binary frame with fragmentation or extension bits. When using fragmentation, the next fragments must be sent with sendContinuationFrame.
        Parameters:
        payload - a binary payload
        finalFragment - flag indicating whether or not 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

        io.netty.util.concurrent.Future<Void> sendBinaryFrame​(io.netty.buffer.ByteBuf payload,
                                                              boolean finalFragment,
                                                              int rsv)
        Allows sending a binary frame with fragmentation or extension bits. When using fragmentation, the next fragments must be sent with sendContinuationFrame.
        Parameters:
        payload - a ByteBuf payload
        finalFragment - flag indicating whether or not 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

        io.netty.util.concurrent.Future<Void> sendContinuationFrame​(String payload,
                                                                    boolean finalFragment,
                                                                    int rsv)
        Send a text continuation frame. The last fragment must have finalFragment set to true.
        Parameters:
        payload - the text fragment
        finalFragment - flag indicating whether or not 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

        io.netty.util.concurrent.Future<Void> sendContinuationFrame​(byte[] payload,
                                                                    boolean finalFragment,
                                                                    int rsv)
        Send a binary continuation frame. The last fragment must have finalFragment set to true.
        Parameters:
        payload - the binary fragment
        finalFragment - flag indicating whether or not 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

        io.netty.util.concurrent.Future<Void> sendContinuationFrame​(io.netty.buffer.ByteBuf payload,
                                                                    boolean finalFragment,
                                                                    int rsv)
        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.
        Parameters:
        payload - a ByteBuf fragment
        finalFragment - flag indicating whether or not 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

        io.netty.util.concurrent.Future<Void> sendPingFrame()
        Send a empty ping frame
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendPingFrame

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

        io.netty.util.concurrent.Future<Void> sendPingFrame​(io.netty.buffer.ByteBuf payload)
        Send a ping frame with a ByteBuf payload (limited to 125 bytes or less).
        Parameters:
        payload - the payload.
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendPongFrame

        io.netty.util.concurrent.Future<Void> sendPongFrame()
        Send a empty pong frame
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendPongFrame

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

        io.netty.util.concurrent.Future<Void> sendPongFrame​(io.netty.buffer.ByteBuf payload)
        Send a pong frame with a ByteBuf payload (limited to 125 bytes or less).
        Parameters:
        payload - the payload.
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendCloseFrame

        io.netty.util.concurrent.Future<Void> sendCloseFrame()
        Send a empty close frame.
        Returns:
        a future that will be completed once the frame will be actually written on the wire
      • sendCloseFrame

        io.netty.util.concurrent.Future<Void> sendCloseFrame​(int statusCode,
                                                             String reasonText)
        Send a empty close frame.
        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

        boolean isOpen()
        Returns:
        true if the WebSocket is open/connected.