This example has a simple echo responder that will allow the server to initiate requests back to the client.
https://github.com/rsocket/rsocket-js/blob/c539b3a42d56780011392fc06ebd488d09f929da/packages/rsocket-examples/src/LeaseClientExample.js
class EchoResponder implements Responder<string, string> {
metadataPush(payload: Payload<string, string>): Single<void> {
return Single.error(new Error('not implemented'));
}
fireAndForget(payload: Payload<string, string>): void {
logRequest('fire-and-forget', payload);
}
So you could connect a socket, not initiate any requests from client->server, but wait for server->client requests.
const client = new RSocketClient({
setup: {
dataMimeType: 'text/plain',
keepAlive: 1000000,
lifetime: 100000,
metadataMimeType: 'text/plain',
},
responder: new EchoResponder(),
leases: () =>
new Leases()
.receiver(receivedLeasesLogger)
.sender(stats => periodicLeaseSender(10000, 7000, 10)),
transport: getClientTransport(address.host, address.port),
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…