public class NettyChannelConnection extends AbstractConnection implements TcpBinding
A NIO connection based on Netty.
| Constructor and Description |
|---|
NettyChannelConnection(io.netty.channel.Channel channel,
StreamHandler streamHandler,
java.util.function.BiConsumer<java.lang.String,StreamElement> onRead,
java.util.function.Supplier<javax.xml.bind.Unmarshaller> unmarshallerSupplier,
java.util.function.BiConsumer<java.lang.String,StreamElement> onWrite,
java.util.function.Supplier<javax.xml.bind.Marshaller> marshallerSupplier,
java.util.function.Consumer<java.lang.Throwable> onException,
ConnectionConfiguration connectionConfiguration) |
| 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.
|
java.util.concurrent.CompletionStage<java.lang.Void> |
open(SessionOpen sessionOpen)
Opens the XML stream to the peer entity.
|
void |
secureConnection()
Secures the connection with TLS.
|
java.util.concurrent.CompletionStage<java.lang.Void> |
send(StreamElement streamElement)
Sends an element to the peer entity.
|
java.lang.String |
toString() |
java.util.concurrent.CompletionStage<java.lang.Void> |
write(StreamElement streamElement)
Writes the element to the stream without really sending it.
|
close, closeAsync, closeAsync, getConfiguration, getStreamId, isUsingAcknowledgementsequals, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, closeAsync, closeAsync, getConfiguration, getStreamId, isUsingAcknowledgementspublic NettyChannelConnection(io.netty.channel.Channel channel,
StreamHandler streamHandler,
java.util.function.BiConsumer<java.lang.String,StreamElement> onRead,
java.util.function.Supplier<javax.xml.bind.Unmarshaller> unmarshallerSupplier,
java.util.function.BiConsumer<java.lang.String,StreamElement> onWrite,
java.util.function.Supplier<javax.xml.bind.Marshaller> marshallerSupplier,
java.util.function.Consumer<java.lang.Throwable> onException,
ConnectionConfiguration connectionConfiguration)
public final java.net.InetSocketAddress getRemoteAddress()
ConnectionGets the remote address of this connection.
getRemoteAddress in interface Connectionpublic 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 final java.util.concurrent.CompletionStage<java.lang.Void> send(StreamElement streamElement)
Connectionsend in interface ConnectionstreamElement - The element.public final java.util.concurrent.CompletionStage<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 void secureConnection()
throws java.lang.Exception
TcpBindingSecures the connection with TLS.
secureConnection in interface TcpBindingjava.lang.Exception - Any exception which may occur during TLS handshake.public final void compressConnection(java.lang.String method,
java.lang.Runnable onSuccess)
Compresses the connection.
compressConnection in interface TcpBindingmethod - The compression method. Supported methods are: “zlib”, “deflate” and “gzip”.onSuccess - Invoked after the compression method has been chosen, but before compression is applied.java.lang.IllegalArgumentException - If the compression method is unknown.public final boolean isSecure()
ConnectionIndicates whether this connection is secured by TLS/SSL.
isSecure 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.lang.String toString()
toString in class java.lang.ObjectCopyright © 2014–2019 XMPP.rocks. All rights reserved.