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

public final Class WebsocketDuplexConnection

extends BaseDuplexConnection
Class Inheritance
Imports
io.netty.buffer.ByteBuf, .ByteBufAllocator, io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame, io.rsocket.DuplexConnection, .RSocketErrorException, io.rsocket.frame.ErrorFrameCodec, 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 a Websocket.

rsocket-java strongly assumes that each ByteBuf is encoded with the length. This is not true for message oriented transports so this must be specifically dropped from Frames sent and stitched back on for frames received.

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
WebsocketDuplexConnection(Connection
the Connection to for managing the server
connection
)

Creates a new instance

public
WebsocketDuplexConnection(String side, Connection
the Connection to 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 String
toString()

Overrides java.lang.Object.toString.

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

Field Detail

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

Constructor Detail

WebsocketDuplexConnectionback to summary
public WebsocketDuplexConnection(Connection connection)

Creates a new instance

Parameters
connection:Connection

the Connection to for managing the server

WebsocketDuplexConnectionback to summary
public WebsocketDuplexConnection(String side, Connection connection)

Creates a new instance

Parameters
connection:Connection

the Connection to 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
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