Class JettyWebSocketRemoteEndpoint
- java.lang.Object
-
- org.eclipse.jetty.websocket.common.JettyWebSocketRemoteEndpoint
-
- All Implemented Interfaces:
RemoteEndpoint
public class JettyWebSocketRemoteEndpoint extends java.lang.Object implements RemoteEndpoint
-
-
Constructor Summary
Constructors Constructor Description JettyWebSocketRemoteEndpoint(CoreSession coreSession, BatchMode batchMode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Initiate close of the Remote with no status code (no payload)voidclose(int statusCode, java.lang.String reason)Initiate close of the Remote with specified status code and optional reason phrasevoidflush()Flushes messages that may have been batched by the implementation.BatchModegetBatchMode()java.net.SocketAddressgetRemoteAddress()Get the SocketAddress for the established connection.voidsendBytes(java.nio.ByteBuffer data)Send a binary message, returning when all bytes of the message has been transmitted.voidsendBytes(java.nio.ByteBuffer data, WriteCallback callback)Initiates the asynchronous transmission of a binary message.voidsendPartialBytes(java.nio.ByteBuffer fragment, boolean isLast)Send a binary message in pieces, blocking until all of the message has been transmitted.voidsendPartialBytes(java.nio.ByteBuffer fragment, boolean isLast, WriteCallback callback)Initiates the asynchronous transmission of a partial binary message.voidsendPartialString(java.lang.String fragment, boolean isLast)Send a text message in pieces, blocking until all of the message has been transmitted.voidsendPartialString(java.lang.String fragment, boolean isLast, WriteCallback callback)Initiates the asynchronous transmission of a partial text message.voidsendPing(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.voidsendPing(java.nio.ByteBuffer applicationData, WriteCallback callback)Asynchronously send a Ping message containing the given application data to the remote endpoint.voidsendPong(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.voidsendPong(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.voidsendString(java.lang.String text)Send a text message, blocking until all bytes of the message has been transmitted.voidsendString(java.lang.String text, WriteCallback callback)Initiates the asynchronous transmission of a text message.voidsetBatchMode(BatchMode mode)Set the batch mode with which messages are sent.
-
-
-
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.IOExceptionDescription copied from interface:RemoteEndpointSend a text message, blocking until all bytes of the message has been transmitted.Note: this is a blocking call
- Specified by:
sendStringin interfaceRemoteEndpoint- 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:RemoteEndpointInitiates 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:
sendStringin interfaceRemoteEndpoint- Parameters:
text- the text being sentcallback- callback to notify of success or failure of the write operation
-
sendBytes
public void sendBytes(java.nio.ByteBuffer data) throws java.io.IOExceptionDescription copied from interface:RemoteEndpointSend a binary message, returning when all bytes of the message has been transmitted.Note: this is a blocking call
- Specified by:
sendBytesin interfaceRemoteEndpoint- 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:RemoteEndpointInitiates 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:
sendBytesin interfaceRemoteEndpoint- Parameters:
data- the data being sentcallback- callback to notify of success or failure of the write operation
-
sendPartialBytes
public void sendPartialBytes(java.nio.ByteBuffer fragment, boolean isLast) throws java.io.IOExceptionDescription copied from interface:RemoteEndpointSend 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:
sendPartialBytesin interfaceRemoteEndpoint- Parameters:
fragment- the piece of the message being sentisLast- 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:RemoteEndpointInitiates 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:
sendPartialBytesin interfaceRemoteEndpoint- Parameters:
fragment- the data being sentisLast- true if this is the last piece of the partial bytescallback- callback to notify of success or failure of the write operation
-
sendPartialString
public void sendPartialString(java.lang.String fragment, boolean isLast) throws java.io.IOExceptionDescription copied from interface:RemoteEndpointSend 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:
sendPartialStringin interfaceRemoteEndpoint- Parameters:
fragment- the piece of the message being sentisLast- 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:RemoteEndpointInitiates 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:
sendPartialStringin interfaceRemoteEndpoint- Parameters:
fragment- the text being sentisLast- true if this is the last piece of the partial bytescallback- callback to notify of success or failure of the write operation
-
sendPing
public void sendPing(java.nio.ByteBuffer applicationData) throws java.io.IOExceptionDescription copied from interface:RemoteEndpointSend 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:
sendPingin interfaceRemoteEndpoint- 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:RemoteEndpointAsynchronously 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:
sendPingin interfaceRemoteEndpoint- Parameters:
applicationData- the data to be carried in the ping requestcallback- callback to notify of success or failure of the write operation
-
sendPong
public void sendPong(java.nio.ByteBuffer applicationData) throws java.io.IOExceptionDescription copied from interface:RemoteEndpointAllows 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:
sendPongin interfaceRemoteEndpoint- 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:RemoteEndpointAllows 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:
sendPongin interfaceRemoteEndpoint- Parameters:
applicationData- the application data to be carried in the pong response.callback- callback to notify of success or failure of the write operation
-
getBatchMode
public BatchMode getBatchMode()
- Specified by:
getBatchModein interfaceRemoteEndpoint- Returns:
- the batch mode with which messages are sent.
- See Also:
RemoteEndpoint.flush()
-
setBatchMode
public void setBatchMode(BatchMode mode)
Description copied from interface:RemoteEndpointSet the batch mode with which messages are sent.- Specified by:
setBatchModein interfaceRemoteEndpoint- Parameters:
mode- the batch mode to use- See Also:
RemoteEndpoint.flush()
-
getRemoteAddress
public java.net.SocketAddress getRemoteAddress()
Description copied from interface:RemoteEndpointGet the SocketAddress for the established connection.- Specified by:
getRemoteAddressin interfaceRemoteEndpoint- Returns:
- the SocketAddress for the established connection.
-
flush
public void flush() throws java.io.IOExceptionDescription copied from interface:RemoteEndpointFlushes messages that may have been batched by the implementation.- Specified by:
flushin interfaceRemoteEndpoint- Throws:
java.io.IOException- if the flush fails
-
-