Skip to content

Instantly share code, notes, and snippets.

@StevenCurran
Last active November 10, 2022 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StevenCurran/c486306b55187064a9d7f066d15d797e to your computer and use it in GitHub Desktop.
Save StevenCurran/c486306b55187064a9d7f066d15d797e to your computer and use it in GitHub Desktop.
import reactor.netty.DisposableServer;
import reactor.netty.tcp.TcpServer;
public class Application {
public static void main(String[] args) {
DisposableServer server =
TcpServer.create()
//inbound.connection.addHandlerLast() Is there a combiner I can use here?
.handle((inbound, outbound) -> {
//Tried to concat here, but then the flatMap is never called.
//return inbound.receive().asString().reduce(String::concat)
return inbound.receive().asString().flatMap(s -> {
//this is chunked, but I need the S to be the complete string.
NettyOutbound out = outbound.sendString(Mono.just(s.toUpperCase()));
return out
})
.bindNow();
server.onDispose()
.block();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment