public final class SocketConnection extends AbstractConnection implements TcpBinding
The default TCP socket connection as described in TCP Binding.
If no hostname is set (null or empty) the connection tries to resolve the hostname via an SRV DNS lookup.
This class is unconditionally thread-safe.
| Constructor and Description |
|---|
SocketConnection(java.net.Socket socket,
XmppSession xmppSession,
TcpConnectionConfiguration configuration) |
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletionStage<java.lang.Void> |
closeFuture()
Returns a future which is complete, when the connection is closed.
|
void |
compressConnection(java.lang.String method,
java.lang.Runnable onSuccess)
Compresses the connection.
|
void |
flush()
Flushes the connection.
|
java.net.InetSocketAddress |
getRemoteAddress()
Gets the remote address 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.
|
java.util.concurrent.CompletionStage<java.lang.Void> |
open(SessionOpen sessionOpen)
Opens the XML stream to the peer entity.
|
void |
secureConnection()
This method is called from the reader thread.
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
send(StreamElement element)
Sends an element to the peer entity.
|
java.lang.String |
toString() |
java.util.concurrent.CompletableFuture<java.lang.Void> |
write(StreamElement streamElement)
Writes the element to the stream without really sending it.
|
close, closeAsync, closeAsync, getConfiguration, getStreamIdequals, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, closeAsync, closeAsync, getConfiguration, getStreamIdpublic SocketConnection(java.net.Socket socket,
XmppSession xmppSession,
TcpConnectionConfiguration configuration)
public final java.util.concurrent.CompletionStage<java.lang.Void> open(SessionOpen sessionOpen)
ConnectionOpens the XML stream to the peer entity.
open in interface ConnectionsessionOpen - The session open information.public boolean isSecure()
ConnectionIndicates whether this connection is secured by TLS/SSL.
isSecure in interface Connectionpublic void secureConnection()
throws java.io.IOException,
java.security.cert.CertificateException,
java.security.NoSuchAlgorithmException
This method is called from the reader thread. Because it accesses shared data (socket, outputStream, inputStream) it should be synchronized.
secureConnection in interface TcpBindingjava.io.IOExceptionjava.security.cert.CertificateExceptionjava.security.NoSuchAlgorithmExceptionpublic void compressConnection(java.lang.String method,
java.lang.Runnable onSuccess)
throws java.lang.Exception
TcpBindingCompresses the connection.
compressConnection in interface TcpBindingmethod - The compression method.onSuccess - Invoked after the compression method has been chosen, but before compression is applied.java.lang.Exceptionpublic final java.util.concurrent.CompletableFuture<java.lang.Void> send(StreamElement element)
Connectionsend in interface Connectionelement - The element.public final java.util.concurrent.CompletableFuture<java.lang.Void> write(StreamElement streamElement)
ConnectionWrites the element to the stream without really sending it. It must be flushed.
write in interface ConnectionstreamElement - The element.public final void flush()
ConnectionFlushes the connection. Any buffered elements written via Connection.write(StreamElement) are sent.
flush in interface Connectionpublic final java.util.concurrent.CompletionStage<java.lang.Void> closeFuture()
ConnectionReturns a future which is complete, when the connection is closed.
closeFuture in interface Connectionpublic final java.net.InetSocketAddress getRemoteAddress()
ConnectionGets the remote address of this connection.
getRemoteAddress in interface Connectionpublic final boolean isUsingAcknowledgements()
ConnectionIndicates whether this connection uses acknowledgements, e.g. by means of stream management or BOSH acks.
isUsingAcknowledgements in interface ConnectionisUsingAcknowledgements in class AbstractConnectionpublic final java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2014–2019 XMPP.rocks. All rights reserved.