io.rsocket.core.ClientSetup Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rsocket-core Show documentation
Show all versions of rsocket-core Show documentation
Core functionality for the RSocket library
package io.rsocket.core;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.rsocket.DuplexConnection;
import java.nio.channels.ClosedChannelException;
import reactor.core.publisher.Mono;
import reactor.util.function.Tuple2;
import reactor.util.function.Tuples;
abstract class ClientSetup {
abstract Mono> init(DuplexConnection connection);
}
class DefaultClientSetup extends ClientSetup {
@Override
Mono> init(DuplexConnection connection) {
return Mono.create(
sink -> sink.onRequest(__ -> sink.success(Tuples.of(Unpooled.EMPTY_BUFFER, connection))));
}
}
class ResumableClientSetup extends ClientSetup {
@Override
Mono> init(DuplexConnection connection) {
return Mono.>create(
sink -> sink.onRequest(__ -> new SetupHandlingDuplexConnection(connection, sink)))
.or(connection.onClose().then(Mono.error(ClosedChannelException::new)));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy