Package rocks.xmpp.core.net
Interface Connection
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
AbstractConnection
,BoshConnection
,JakartaWebSocketConnection
,NettyChannelConnection
,SocketConnection
,TcpConnection
,WebSocketConnection
public interface Connection extends AutoCloseable
Represents a bi-directional XMPP connection.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
CompletionStage<Void>
closeAsync()
Asynchronously closes the connection.CompletionStage<Void>
closeAsync(StreamError streamError)
Asynchronously closes the connection with a stream error.CompletionStage<Void>
closeFuture()
Returns a future which is complete, when the connection is closed.void
flush()
Flushes the connection.ConnectionConfiguration
getConfiguration()
Gets the configuration used to create this connection.InetSocketAddress
getRemoteAddress()
Gets the remote address of this connection.String
getStreamId()
Gets the stream id of this connection.boolean
isSecure()
Indicates whether this connection is secured by TLS/SSL.boolean
isUsingAcknowledgements()
Indicates whether this connection uses acknowledgements, e.g. by means of stream management or BOSH acks.CompletionStage<Void>
open(SessionOpen sessionOpen)
Opens the XML stream to the peer entity.CompletionStage<Void>
send(StreamElement streamElement)
Sends an element to the peer entity.CompletionStage<Void>
write(StreamElement streamElement)
Writes the element to the stream without really sending it.
-
-
-
Method Detail
-
getRemoteAddress
InetSocketAddress getRemoteAddress()
Gets the remote address of this connection.- Returns:
- The remote address.
-
getConfiguration
ConnectionConfiguration getConfiguration()
Gets the configuration used to create this connection.- Returns:
- The
-
isUsingAcknowledgements
boolean isUsingAcknowledgements()
Indicates whether this connection uses acknowledgements, e.g. by means of stream management or BOSH acks.- Returns:
- If this connection uses acknowledgements.
-
open
CompletionStage<Void> open(SessionOpen sessionOpen)
Opens the XML stream to the peer entity.- Parameters:
sessionOpen
- The session open information.- Returns:
- The completion stage, which is complete, if the session has been opened, i.e. the element has been sent.
-
send
CompletionStage<Void> send(StreamElement streamElement)
- Parameters:
streamElement
- The element.- Returns:
- The future representing the send process and which allows to cancel it.
-
write
CompletionStage<Void> write(StreamElement streamElement)
Writes the element to the stream without really sending it. It must be flushed.- Parameters:
streamElement
- The element.- Returns:
- The send future.
-
flush
void flush()
Flushes the connection. Any buffered elements written viawrite(StreamElement)
are sent.
-
isSecure
boolean isSecure()
Indicates whether this connection is secured by TLS/SSL.- Returns:
- True, if this connection is secured.
-
getStreamId
String getStreamId()
Gets the stream id of this connection.- Returns:
- The stream id.
-
closeAsync
CompletionStage<Void> closeAsync()
Asynchronously closes the connection.Closing usually involves a round-trip with the peer on the XMPP layer first by sending a closing stream element, then waiting on the response and then closing the underlying transport layer.
Implementations wait a maximum of 500ms for the XMPP level close.
- Returns:
- The future, which is complete, when the connection is closed.
- See Also:
close()
-
closeAsync
CompletionStage<Void> closeAsync(StreamError streamError)
Asynchronously closes the connection with a stream error.- Parameters:
streamError
- The stream error, which is sent before closing the stream.- Returns:
- The completion stage, which is complete, when the connection is closed.
- See Also:
closeAsync()
-
closeFuture
CompletionStage<Void> closeFuture()
Returns a future which is complete, when the connection is closed.- Returns:
- The close future.
-
close
void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
-