Package rocks.xmpp.core.net
Class AbstractConnection
- java.lang.Object
-
- rocks.xmpp.core.net.AbstractConnection
-
- All Implemented Interfaces:
AutoCloseable,Connection,StreamHandler
- Direct Known Subclasses:
BoshConnection,TcpConnection,WebSocketConnection
public abstract class AbstractConnection extends Object implements Connection, StreamHandler
An abstract connection implementation.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the connection.CompletionStage<Void>closeAsync()Asynchronously closes the connection.CompletionStage<Void>closeAsync(StreamError streamError)Asynchronously closes the connection with a stream error.ConnectionConfigurationgetConfiguration()Gets the configuration used to create this connection.StringgetStreamId()Gets the stream id of this connection.booleanhandleElement(Object streamElement)Handles an inbound stream element.booleanisClosed()If the connection is closed.booleanisUsingAcknowledgements()Indicates whether this connection uses acknowledgements, e.g. by means of stream management or BOSH acks.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface rocks.xmpp.core.net.Connection
closeFuture, flush, getRemoteAddress, isSecure, open, send, write
-
-
-
-
Method Detail
-
getConfiguration
public final ConnectionConfiguration getConfiguration()
Description copied from interface:ConnectionGets the configuration used to create this connection.- Specified by:
getConfigurationin interfaceConnection- Returns:
- The
-
isUsingAcknowledgements
public boolean isUsingAcknowledgements()
Description copied from interface:ConnectionIndicates whether this connection uses acknowledgements, e.g. by means of stream management or BOSH acks.- Specified by:
isUsingAcknowledgementsin interfaceConnection- Returns:
- If this connection uses acknowledgements.
-
handleElement
public boolean handleElement(Object streamElement)
Description copied from interface:StreamHandlerHandles an inbound stream element.- Specified by:
handleElementin interfaceStreamHandler- Parameters:
streamElement- The stream element.- Returns:
- True, if the stream must be restarted.
-
getStreamId
public final String getStreamId()
Description copied from interface:ConnectionGets the stream id of this connection.- Specified by:
getStreamIdin interfaceConnection- Returns:
- The stream id.
-
closeAsync
public final CompletionStage<Void> closeAsync()
Description copied from interface:ConnectionAsynchronously 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.
- Specified by:
closeAsyncin interfaceConnection- Returns:
- The future, which is complete, when the connection is closed.
- See Also:
Connection.close()
-
closeAsync
public final CompletionStage<Void> closeAsync(StreamError streamError)
Description copied from interface:ConnectionAsynchronously closes the connection with a stream error.- Specified by:
closeAsyncin interfaceConnection- 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:
Connection.closeAsync()
-
close
public final void close() throws ExceptionCloses the connection. This method blocks until everything is closed (max. 1s).- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConnection- Throws:
Exception- If the close failed.- See Also:
closeAsync()
-
isClosed
public final boolean isClosed()
If the connection is closed.- Returns:
- True, if closed.
-
-