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, isUsingAcknowledgements
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
close, closeAsync, closeAsync, getConfiguration, getStreamId, isUsingAcknowledgements
public 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()
Connection
Gets the remote address of this connection.
getRemoteAddress
in interface Connection
public final java.util.concurrent.CompletionStage<java.lang.Void> open(SessionOpen sessionOpen)
Connection
Opens the XML stream to the peer entity.
open
in interface Connection
sessionOpen
- The session open information.public final java.util.concurrent.CompletionStage<java.lang.Void> send(StreamElement streamElement)
Connection
send
in interface Connection
streamElement
- The element.public final java.util.concurrent.CompletionStage<java.lang.Void> write(StreamElement streamElement)
Connection
Writes the element to the stream without really sending it. It must be flushed.
write
in interface Connection
streamElement
- The element.public final void flush()
Connection
Flushes the connection. Any buffered elements written via Connection.write(StreamElement)
are sent.
flush
in interface Connection
public void secureConnection() throws java.lang.Exception
TcpBinding
Secures the connection with TLS.
secureConnection
in interface TcpBinding
java.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 TcpBinding
method
- 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()
Connection
Indicates whether this connection is secured by TLS/SSL.
isSecure
in interface Connection
public final java.util.concurrent.CompletionStage<java.lang.Void> closeFuture()
Connection
Returns a future which is complete, when the connection is closed.
closeFuture
in interface Connection
public final java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2014–2019 XMPP.rocks. All rights reserved.