rsocket-js client can be used to communicate with any RSocket Server implemented against the same protocol version as the client, and which implements the same transport as the client.
Available transports for
RSocketClient class is exported from the
rsocket-core NPM package, and should be passed an instance of one of the available transports.
To get started creating an RSocket client, you will first need to install the
rsocket-core NPM package, and atleast one transport protocol implementation. See the WebSocket client example below.
rsocket-core package exposes the the following types:
RSocketClient is used to create an instance of a client. The clients connection does not initialize until the
connect method is invoked.
By default the
metadata of each payload are passed through to the
transport layer as-is. This is appropriate for sending/receiving strings/binary.
To send/receive JSON instead, pass
serializers: JsonSerializers (imported from
This will typically be an instance of
rsocket-websocket-client, though any value conforming to the
protocol is allowed.
This method opens the connection to the peer. Internally this calls
connect() on the
transport client. See below for the
This interface represents an instance of a rsocket peer-to-peer connection, providing the five core interactions (fire/forget, request/reponse, etc.):
This method sends data/metadata to the server without waiting for a response. The data is sent immediately.
This method sends data/metadata to the server, which returns a single response. The data is
sent lazily when the returned
Single is subscribed to.
This method sends data/metadata to the server, which returns a stream of responses. The semantics
of the stream are application-specific. For example, the stream may represent
updates to a single conceptual value over time, items in an incrementally loaded
list, events, etc. The data is sent to the peer lazily when the returned
Flowable is subscribed to and
request(n) is called to signal demand.
This method establishes an understanding between a client and a server where each intends to send and receive streams of data from the other. Each actor in this relationship is responsible for signaling to the other that they are ready to receive data by invoking
n is the max number of payloads the actor is comfortable handling. Conceptually,
requestChannel can be thought of as two entities 'polling' from each other by signaling to the others that they are ready to accept
n number of messages. Inversely,
requestChannel can be leveraged to facilitate a consistent stream of data transfer payloads between client and server by each (or either) invoking
0x7fffffff is the max integer value for
This method sends metadata only to the server without waiting for a response. The payload is sent immediately. This method is not for the direct application usage and should be used to exchange some service level information