Package rocks.xmpp.websocket.net
Class JakartaWebSocketConnection
- java.lang.Object
-
- rocks.xmpp.core.net.AbstractConnection
-
- rocks.xmpp.websocket.net.WebSocketConnection
-
- rocks.xmpp.websocket.net.JakartaWebSocketConnection
-
- All Implemented Interfaces:
AutoCloseable
,Connection
,StreamHandler
public final class JakartaWebSocketConnection extends WebSocketConnection
Generic WebSocket connection which is based on Jakarta WebSocket API.The connection is implemented from a server point of view, i.e. during stream restarts no "open" element is sent.
Client implementations may use this class and pass their own message handler which restarts the stream.
-
-
Constructor Summary
Constructors Constructor Description JakartaWebSocketConnection(javax.websocket.Session session, ConnectionConfiguration connectionConfiguration, StreamHandler streamHandler, Consumer<Throwable> onException, CompletionStage<Void> closeFuture, javax.websocket.MessageHandler.Whole<StreamElement> messageHandler)
Creates
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletionStage<Void>
closeConnection()
void
flush()
Flushes the connection.InetSocketAddress
getRemoteAddress()
Gets the remote address of this connection.String
toString()
CompletableFuture<Void>
write(StreamElement streamElement)
Writes the element to the stream without really sending it.-
Methods inherited from class rocks.xmpp.websocket.net.WebSocketConnection
closeFuture, isSecure, open, send
-
Methods inherited from class rocks.xmpp.core.net.AbstractConnection
close, closeAsync, closeAsync, getConfiguration, getStreamId, handleElement, isClosed, isUsingAcknowledgements
-
-
-
-
Constructor Detail
-
JakartaWebSocketConnection
public JakartaWebSocketConnection(javax.websocket.Session session, ConnectionConfiguration connectionConfiguration, StreamHandler streamHandler, Consumer<Throwable> onException, CompletionStage<Void> closeFuture, javax.websocket.MessageHandler.Whole<StreamElement> messageHandler)
Creates- Parameters:
session
- The session.connectionConfiguration
- The configuration.streamHandler
- Handles inbound elements.onException
- Handles exceptions.closeFuture
- The close future, which is completed when the session is closed.messageHandler
- Optional message handler; if null the default handling of this connection is used.
-
-
Method Detail
-
closeConnection
public final CompletionStage<Void> closeConnection()
-
getRemoteAddress
public final InetSocketAddress getRemoteAddress()
Description copied from interface:Connection
Gets the remote address of this connection.- Returns:
- The remote address.
-
write
public final CompletableFuture<Void> write(StreamElement streamElement)
Description copied from interface:Connection
Writes the element to the stream without really sending it. It must be flushed.- Parameters:
streamElement
- The element.- Returns:
- The send future.
-
flush
public final void flush()
Description copied from interface:Connection
Flushes the connection. Any buffered elements written viaConnection.write(StreamElement)
are sent.
-
-