Class JettyWebSocketRemoteEndpoint

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Initiate close of the Remote with no status code (no payload)
      void close​(int statusCode, java.lang.String reason)
      Initiate close of the Remote with specified status code and optional reason phrase
      void flush()
      Flushes messages that may have been batched by the implementation.
      BatchMode getBatchMode()  
      int getMaxOutgoingFrames()
      Get the maximum number of data frames allowed to be waiting to be sent at any one time.
      java.net.SocketAddress getRemoteAddress()
      Get the SocketAddress for the established connection.
      void sendBytes​(java.nio.ByteBuffer data)
      Send a binary message, returning when all bytes of the message has been transmitted.
      void sendBytes​(java.nio.ByteBuffer data, WriteCallback callback)
      Initiates the asynchronous transmission of a binary message.
      void sendPartialBytes​(java.nio.ByteBuffer fragment, boolean isLast)
      Send a binary message in pieces, blocking until all of the message has been transmitted.
      void sendPartialBytes​(java.nio.ByteBuffer fragment, boolean isLast, WriteCallback callback)
      Initiates the asynchronous transmission of a partial binary message.
      void sendPartialString​(java.lang.String fragment, boolean isLast)
      Send a text message in pieces, blocking until all of the message has been transmitted.
      void sendPartialString​(java.lang.String fragment, boolean isLast, WriteCallback callback)
      Initiates the asynchronous transmission of a partial text message.
      void sendPing​(java.nio.ByteBuffer applicationData)
      Send a Ping message containing the given application data to the remote endpoint, blocking until all of the message has been transmitted.
      void sendPing​(java.nio.ByteBuffer applicationData, WriteCallback callback)
      Asynchronously send a Ping message containing the given application data to the remote endpoint.
      void sendPong​(java.nio.ByteBuffer applicationData)
      Allows the developer to send an unsolicited Pong message containing the given application data in order to serve as a unidirectional heartbeat for the session, this will block until all of the message has been transmitted.
      void sendPong​(java.nio.ByteBuffer applicationData, WriteCallback callback)
      Allows the developer to asynchronously send an unsolicited Pong message containing the given application data in order to serve as a unidirectional heartbeat for the session.
      void sendString​(java.lang.String text)
      Send a text message, blocking until all bytes of the message has been transmitted.
      void sendString​(java.lang.String text, WriteCallback callback)
      Initiates the asynchronous transmission of a text message.
      void setBatchMode​(BatchMode mode)
      Set the batch mode with which messages are sent.
      void setMaxOutgoingFrames​(int maxOutgoingFrames)
      Set the maximum number of data frames allowed to be waiting to be sent at any one time.
      • Methods inherited from class java.lang.Object

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

      • JettyWebSocketRemoteEndpoint

        public JettyWebSocketRemoteEndpoint​(CoreSession coreSession,
                                            BatchMode batchMode)
    • Method Detail

      • close

        public void close()
        Initiate close of the Remote with no status code (no payload)
        Since:
        10.0
      • close

        public void close​(int statusCode,
                          java.lang.String reason)
        Initiate close of the Remote with specified status code and optional reason phrase
        Parameters:
        statusCode - the status code (must be valid and can be sent)
        reason - optional reason code
        Since:
        10.0
      • sendString

        public void sendString​(java.lang.String text)
                        throws java.io.IOException
        Description copied from interface: RemoteEndpoint
        Send a text message, blocking until all bytes of the message has been transmitted.

        Note: this is a blocking call

        Specified by:
        sendString in interface RemoteEndpoint
        Parameters:
        text - the message to be sent
        Throws:
        java.io.IOException - if unable to send the text message
      • sendString

        public void sendString​(java.lang.String text,
                               WriteCallback callback)
        Description copied from interface: RemoteEndpoint
        Initiates the asynchronous transmission of a text message. This method may return before the message is transmitted. Developers may provide a callback to be notified when the message has been transmitted or resulted in an error.
        Specified by:
        sendString in interface RemoteEndpoint
        Parameters:
        text - the text being sent
        callback - callback to notify of success or failure of the write operation
      • sendBytes

        public void sendBytes​(java.nio.ByteBuffer data)
                       throws java.io.IOException
        Description copied from interface: RemoteEndpoint
        Send a binary message, returning when all bytes of the message has been transmitted.

        Note: this is a blocking call

        Specified by:
        sendBytes in interface RemoteEndpoint
        Parameters:
        data - the message to be sent
        Throws:
        java.io.IOException - if unable to send the bytes
      • sendBytes

        public void sendBytes​(java.nio.ByteBuffer data,
                              WriteCallback callback)
        Description copied from interface: RemoteEndpoint
        Initiates the asynchronous transmission of a binary message. This method returns before the message is transmitted. Developers may provide a callback to be notified when the message has been transmitted or resulted in an error.
        Specified by:
        sendBytes in interface RemoteEndpoint
        Parameters:
        data - the data being sent
        callback - callback to notify of success or failure of the write operation
      • sendPartialBytes

        public void sendPartialBytes​(java.nio.ByteBuffer fragment,
                                     boolean isLast)
                              throws java.io.IOException
        Description copied from interface: RemoteEndpoint
        Send a binary message in pieces, blocking until all of the message has been transmitted. The runtime reads the message in order. Non-final pieces are sent with isLast set to false. The final piece must be sent with isLast set to true.
        Specified by:
        sendPartialBytes in interface RemoteEndpoint
        Parameters:
        fragment - the piece of the message being sent
        isLast - true if this is the last piece of the partial bytes
        Throws:
        java.io.IOException - if unable to send the partial bytes
      • sendPartialBytes

        public void sendPartialBytes​(java.nio.ByteBuffer fragment,
                                     boolean isLast,
                                     WriteCallback callback)
        Description copied from interface: RemoteEndpoint
        Initiates the asynchronous transmission of a partial binary message. This method returns before the message is transmitted. The runtime reads the message in order. Non-final pieces are sent with isLast set to false. The final piece must be sent with isLast set to true. Developers may provide a callback to be notified when the message has been transmitted or resulted in an error.
        Specified by:
        sendPartialBytes in interface RemoteEndpoint
        Parameters:
        fragment - the data being sent
        isLast - true if this is the last piece of the partial bytes
        callback - callback to notify of success or failure of the write operation
      • sendPartialString

        public void sendPartialString​(java.lang.String fragment,
                                      boolean isLast)
                               throws java.io.IOException
        Description copied from interface: RemoteEndpoint
        Send a text message in pieces, blocking until all of the message has been transmitted. The runtime reads the message in order. Non-final pieces are sent with isLast set to false. The final piece must be sent with isLast set to true.
        Specified by:
        sendPartialString in interface RemoteEndpoint
        Parameters:
        fragment - the piece of the message being sent
        isLast - true if this is the last piece of the partial bytes
        Throws:
        java.io.IOException - if unable to send the partial bytes
      • sendPartialString

        public void sendPartialString​(java.lang.String fragment,
                                      boolean isLast,
                                      WriteCallback callback)
        Description copied from interface: RemoteEndpoint
        Initiates the asynchronous transmission of a partial text message. This method may return before the message is transmitted. The runtime reads the message in order. Non-final pieces are sent with isLast set to false. The final piece must be sent with isLast set to true. Developers may provide a callback to be notified when the message has been transmitted or resulted in an error.
        Specified by:
        sendPartialString in interface RemoteEndpoint
        Parameters:
        fragment - the text being sent
        isLast - true if this is the last piece of the partial bytes
        callback - callback to notify of success or failure of the write operation
      • sendPing

        public void sendPing​(java.nio.ByteBuffer applicationData)
                      throws java.io.IOException
        Description copied from interface: RemoteEndpoint
        Send a Ping message containing the given application data to the remote endpoint, blocking until all of the message has been transmitted. The corresponding Pong message may be picked up using the MessageHandler.Pong handler.
        Specified by:
        sendPing in interface RemoteEndpoint
        Parameters:
        applicationData - the data to be carried in the ping request
        Throws:
        java.io.IOException - if unable to send the ping
      • sendPing

        public void sendPing​(java.nio.ByteBuffer applicationData,
                             WriteCallback callback)
        Description copied from interface: RemoteEndpoint
        Asynchronously send a Ping message containing the given application data to the remote endpoint. The corresponding Pong message may be picked up using the MessageHandler.Pong handler.
        Specified by:
        sendPing in interface RemoteEndpoint
        Parameters:
        applicationData - the data to be carried in the ping request
        callback - callback to notify of success or failure of the write operation
      • sendPong

        public void sendPong​(java.nio.ByteBuffer applicationData)
                      throws java.io.IOException
        Description copied from interface: RemoteEndpoint
        Allows the developer to send an unsolicited Pong message containing the given application data in order to serve as a unidirectional heartbeat for the session, this will block until all of the message has been transmitted.
        Specified by:
        sendPong in interface RemoteEndpoint
        Parameters:
        applicationData - the application data to be carried in the pong response.
        Throws:
        java.io.IOException - if unable to send the pong
      • sendPong

        public void sendPong​(java.nio.ByteBuffer applicationData,
                             WriteCallback callback)
        Description copied from interface: RemoteEndpoint
        Allows the developer to asynchronously send an unsolicited Pong message containing the given application data in order to serve as a unidirectional heartbeat for the session.
        Specified by:
        sendPong in interface RemoteEndpoint
        Parameters:
        applicationData - the application data to be carried in the pong response.
        callback - callback to notify of success or failure of the write operation
      • getMaxOutgoingFrames

        public int getMaxOutgoingFrames()
        Description copied from interface: RemoteEndpoint
        Get the maximum number of data frames allowed to be waiting to be sent at any one time. The default value is -1, this indicates there is no limit on how many frames can be queued to be sent by the implementation. If the limit is exceeded, subsequent frames sent are failed with a WritePendingException but the connection is not failed and will remain open.
        Specified by:
        getMaxOutgoingFrames in interface RemoteEndpoint
        Returns:
        the max number of frames.
      • setMaxOutgoingFrames

        public void setMaxOutgoingFrames​(int maxOutgoingFrames)
        Description copied from interface: RemoteEndpoint
        Set the maximum number of data frames allowed to be waiting to be sent at any one time. The default value is -1, this indicates there is no limit on how many frames can be queued to be sent by the implementation. If the limit is exceeded, subsequent frames sent are failed with a WritePendingException but the connection is not failed and will remain open.
        Specified by:
        setMaxOutgoingFrames in interface RemoteEndpoint
        Parameters:
        maxOutgoingFrames - the max number of frames.
      • getRemoteAddress

        public java.net.SocketAddress getRemoteAddress()
        Description copied from interface: RemoteEndpoint
        Get the SocketAddress for the established connection.
        Specified by:
        getRemoteAddress in interface RemoteEndpoint
        Returns:
        the SocketAddress for the established connection.
      • flush

        public void flush()
                   throws java.io.IOException
        Description copied from interface: RemoteEndpoint
        Flushes messages that may have been batched by the implementation.
        Specified by:
        flush in interface RemoteEndpoint
        Throws:
        java.io.IOException - if the flush fails