Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 29 additions & 31 deletions rsocket-core/src/main/java/io/rsocket/RSocketFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,28 +228,21 @@ public Mono<RSocket> start() {
ackTimeout,
missedAcks);

Mono<RSocket> wrappedRSocketClient =
Mono.just(rSocketClient).map(plugins::applyClient);

DuplexConnection finalConnection = connection;
return wrappedRSocketClient.flatMap(
wrappedClientRSocket -> {
RSocket unwrappedServerSocket = acceptor.get().apply(wrappedClientRSocket);

Mono<RSocket> wrappedRSocketServer =
Mono.just(unwrappedServerSocket).map(plugins::applyServer);

return wrappedRSocketServer
.doOnNext(
rSocket ->
new RSocketServer(
multiplexer.asServerConnection(),
rSocket,
frameDecoder,
errorConsumer))
.then(finalConnection.sendOne(setupFrame))
.then(wrappedRSocketClient);
});
RSocket wrappedRSocketClient = plugins.applyClient(rSocketClient);

RSocket unwrappedServerSocket = acceptor.get().apply(wrappedRSocketClient);

RSocket wrappedRSocketServer = plugins.applyServer(unwrappedServerSocket);

RSocketServer rSocketServer = new RSocketServer(
multiplexer.asServerConnection(),
wrappedRSocketServer,
frameDecoder,
errorConsumer);

return connection
.sendOne(setupFrame)
.thenReturn(wrappedRSocketClient);
});
}
}
Expand Down Expand Up @@ -332,7 +325,7 @@ public Mono<T> start() {
});
}

private Mono<? extends Void> processSetupFrame(
private Mono<Void> processSetupFrame(
ClientServerInputMultiplexer multiplexer, Frame setupFrame) {
int version = Frame.Setup.version(setupFrame);
if (version != SetupFrameFlyweight.CURRENT_VERSION) {
Expand All @@ -355,15 +348,20 @@ private Mono<? extends Void> processSetupFrame(
errorConsumer,
StreamIdSupplier.serverSupplier());

Mono<RSocket> wrappedRSocketClient = Mono.just(rSocketClient).map(plugins::applyClient);
RSocket wrappedRSocketClient = plugins.applyClient(rSocketClient);

return wrappedRSocketClient
.flatMap(
sender -> acceptor.get().accept(setupPayload, sender).map(plugins::applyServer))
.map(
handler ->
new RSocketServer(
multiplexer.asClientConnection(), handler, frameDecoder, errorConsumer))
return acceptor
.get()
.accept(setupPayload, wrappedRSocketClient)
.doOnNext(unwrappedServerSocket -> {
RSocket wrappedRSocketServer = plugins.applyServer(unwrappedServerSocket);

RSocketServer rSocketServer = new RSocketServer(
multiplexer.asClientConnection(),
wrappedRSocketServer,
frameDecoder,
errorConsumer);
})
.then();
}
}
Expand Down