Package rocks.xmpp.extensions.httpbind
Class BoshConnection
- java.lang.Object
-
- rocks.xmpp.core.net.AbstractConnection
-
- rocks.xmpp.extensions.httpbind.BoshConnection
-
- All Implemented Interfaces:
AutoCloseable
,Connection
,StreamHandler
public abstract class BoshConnection extends AbstractConnection
The abstract base class for BOSH connections.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletionStage<Void>
closeFuture()
Returns a future which is complete, when the connection is closed.long
detach()
Detaches this BOSH session without closing (aka terminating) it.void
flush()
Flushes the connection.InetSocketAddress
getRemoteAddress()
Gets the remote address of this connection.String
getRoute()
Gets the route.String
getSessionId()
Gets the session id of this BOSH 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.CompletableFuture<Void>
send(StreamElement element)
Sends an element to the peer entity.CompletableFuture<Void>
write(StreamElement streamElement)
Writes the element to the stream without really sending it.-
Methods inherited from class rocks.xmpp.core.net.AbstractConnection
close, closeAsync, closeAsync, getConfiguration, getStreamId, handleElement, isClosed
-
-
-
-
Method Detail
-
open
public final CompletionStage<Void> open(SessionOpen sessionOpen)
Description copied from interface:Connection
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.
-
isSecure
public final boolean isSecure()
Description copied from interface:Connection
Indicates whether this connection is secured by TLS/SSL.- Returns:
- True, if this connection is secured.
-
closeFuture
public final CompletionStage<Void> closeFuture()
Description copied from interface:Connection
Returns a future which is complete, when the connection is closed.- Returns:
- The close future.
-
detach
public final long detach()
Detaches this BOSH session without closing (aka terminating) it. This way the BOSH session is still alive on the server and can be ported over to a web page, but new BOSH requests are no longer sent by this connection.- Returns:
- The current request ID (RID) which was used for the last BOSH request.
- See Also:
- https://conversejs.org/docs/html/#prebinding-and-single-session-support
-
send
public final CompletableFuture<Void> send(StreamElement element)
Description copied from interface:Connection
- Parameters:
element
- The element.- Returns:
- The future representing the send process and which allows to cancel it.
-
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.
-
getSessionId
public final String getSessionId()
Gets the session id of this BOSH connection.- Returns:
- The session id.
-
getRemoteAddress
public final InetSocketAddress getRemoteAddress()
Description copied from interface:Connection
Gets the remote address of this connection.- Returns:
- The remote address.
-
isUsingAcknowledgements
public final boolean isUsingAcknowledgements()
Description copied from interface:Connection
Indicates whether this connection uses acknowledgements, e.g. by means of stream management or BOSH acks.- Specified by:
isUsingAcknowledgements
in interfaceConnection
- Overrides:
isUsingAcknowledgements
in classAbstractConnection
- Returns:
- If this connection uses acknowledgements.
-
getRoute
public final String getRoute()
Gets the route.A connection manager MAY be configured to enable sessions with more than one server in different domains. When requesting a session with such a "proxy" connection manager, a client SHOULD include a 'route' attribute that specifies the protocol, hostname, and port of the server with which it wants to communicate, formatted as "proto:host:port" (e.g., "xmpp:example.com:9999").
- Returns:
- The route.
-
-