Top Description Fields Constructors Methods
io.rsocket.transport.netty

public final Class TcpDuplexConnection

extends BaseDuplexConnection
Class Inheritance
Imports
io.netty.buffer.ByteBuf, .ByteBufAllocator, io.rsocket.DuplexConnection, .RSocketErrorException, io.rsocket.frame.ErrorFrameCodec, .FrameLengthCodec, io.rsocket.internal.BaseDuplexConnection, java.net.SocketAddress, java.util.Objects, reactor.core.publisher.Flux, .Mono, reactor.netty.Connection

An implementation of DuplexConnection that connects via TCP.

Field Summary

Modifier and TypeField and Description
private final Connection
private final String
Inherited from io.rsocket.internal.BaseDuplexConnection:
onClosesender

Constructor Summary

AccessConstructor and Description
public
TcpDuplexConnection(Connection
the Connection for managing the server
connection
)

Creates a new instance

public
TcpDuplexConnection(String side, Connection
the Connection for managing the server
connection
)

Creates a new instance

Method Summary

Modifier and TypeMethod and Description
public ByteBufAllocator
alloc()

Implements io.rsocket.DuplexConnection.alloc.

Returns the assigned ByteBufAllocator.
protected void
public Mono<Void>
onClose()

Overrides io.rsocket.internal.BaseDuplexConnection.onClose.

Implements io.rsocket.Closeable.onClose.

Returns a Mono that terminates when the instance is terminated by any reason.
public Flux<ByteBuf>
receive()

Implements io.rsocket.DuplexConnection.receive.

Returns a stream of all Frames received on this connection.
public SocketAddress
remoteAddress()

Implements io.rsocket.DuplexConnection.remoteAddress.

Return the remote address that this connection is connected to.
public void
sendErrorAndClose(RSocketErrorException
to encode in the error frame
e
)

Implements io.rsocket.DuplexConnection.sendErrorAndClose.

Send an error frame and after it is successfully sent, close the connection.
public void
sendFrame(int
to which the given frame relates
streamId
,
ByteBuf
with the encoded content
frame
)

Overrides io.rsocket.internal.BaseDuplexConnection.sendFrame.

Implements io.rsocket.DuplexConnection.sendFrame.

Delivers the given frame to the underlying transport connection.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from io.rsocket.internal.BaseDuplexConnection:
disposeisDisposed

Field Detail

connectionback to summary
private final Connection connection
sideback to summary
private final String side

Constructor Detail

TcpDuplexConnectionback to summary
public TcpDuplexConnection(Connection connection)

Creates a new instance

Parameters
connection:Connection

the Connection for managing the server

TcpDuplexConnectionback to summary
public TcpDuplexConnection(String side, Connection connection)

Creates a new instance

Parameters
connection:Connection

the Connection for managing the server

Method Detail

allocback to summary
public ByteBufAllocator alloc()

Implements io.rsocket.DuplexConnection.alloc.

Doc from io.rsocket.DuplexConnection.alloc.

Returns the assigned ByteBufAllocator.

Returns:ByteBufAllocator

the ByteBufAllocator

Annotations
@Override
doOnCloseback to summary
protected void doOnClose()

Implements abstract io.rsocket.internal.BaseDuplexConnection.doOnClose.

Annotations
@Override
onCloseback to summary
public Mono<Void> onClose()

Overrides io.rsocket.internal.BaseDuplexConnection.onClose.

Implements io.rsocket.Closeable.onClose.

Doc from io.rsocket.Closeable.onClose.

Returns a Mono that terminates when the instance is terminated by any reason. Note, in case of error termination, the cause of error will be propagated as an error signal through org.reactivestreams.Subscriber#onError(Throwable). Otherwise, Subscriber#onComplete() will be called.

Returns:Mono<Void>

a Mono to track completion with success or error of the underlying resource. When the underlying resource is an `RSocket`, the Mono exposes stream 0 (i.e. connection level) errors.

Annotations
@Override
receiveback to summary
public Flux<ByteBuf> receive()

Implements io.rsocket.DuplexConnection.receive.

Doc from io.rsocket.DuplexConnection.receive.

Returns a stream of all Frames received on this connection.

Completion

Returned Publisher MUST never emit a completion event (Subscriber#onComplete()).

Error

Returned Publisher can error with various transport errors. If the underlying physical connection is closed by the peer, then the returned stream from here MUST emit an ClosedChannelException.

Multiple Subscriptions

Returned Publisher is not required to support multiple concurrent subscriptions. RSocket will never have multiple subscriptions to this source. Implementations MUST emit an IllegalStateException for subsequent concurrent subscriptions, if they do not support multiple concurrent subscriptions.

Returns:Flux<ByteBuf>

Stream of all Frames received.

Annotations
@Override
remoteAddressback to summary
public SocketAddress remoteAddress()

Implements io.rsocket.DuplexConnection.remoteAddress.

Doc from io.rsocket.DuplexConnection.remoteAddress.

Return the remote address that this connection is connected to. The returned SocketAddress varies by transport type and should be downcast to obtain more detailed information. For TCP and WebSocket, the address type is java.net.InetSocketAddress. For local transport, it is io.rsocket.transport.local.LocalSocketAddress.

Returns:SocketAddress

the address

Annotations
@Override
sendErrorAndCloseback to summary
public void sendErrorAndClose(RSocketErrorException e)

Implements io.rsocket.DuplexConnection.sendErrorAndClose.

Doc from io.rsocket.DuplexConnection.sendErrorAndClose.

Send an error frame and after it is successfully sent, close the connection.

Parameters
e:RSocketErrorException

to encode in the error frame

Annotations
@Override
sendFrameback to summary
public void sendFrame(int streamId, ByteBuf frame)

Overrides io.rsocket.internal.BaseDuplexConnection.sendFrame.

Implements io.rsocket.DuplexConnection.sendFrame.

Doc from io.rsocket.DuplexConnection.sendFrame.

Delivers the given frame to the underlying transport connection. This method is non-blocking and can be safely executed from multiple threads. This method does not provide any flow-control mechanism.

Parameters
streamId:int

to which the given frame relates

frame:ByteBuf

with the encoded content

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override