/** * Send data to the peer, listen for any error on write and close on terminal signal * (complete|error). <p>A new {@link NettyOutbound} type (or the same) for typed send * sequences. An implementor can therefore specialize the Outbound after a first after * a prepending data publisher. * Note: Nesting any send* method is not supported. * * @param dataStream the dataStream publishing OUT items to write on this channel * * @return A new {@link NettyOutbound} to append further send. It will emit a complete * signal successful sequence write (e.g. after "flush") or any error during write. */ default NettyOutbound send(Publisher<? extends ByteBuf> dataStream) { return sendObject(dataStream); }
/** * Send String to the peer, listen for any error on write and close on terminal signal * (complete|error). If more than one publisher is attached (multiple calls to send()) * completion occurs after all publishers complete. * Note: Nesting any send* method is not supported. * * @param dataStream the dataStream publishing Buffer items to write on this channel * @param charset the encoding charset * * @return A Publisher to signal successful sequence write (e.g. after "flush") or any * error during write */ default NettyOutbound sendString(Publisher<? extends String> dataStream, Charset charset) { return sendObject(ReactorNetty.publisherOrScalarMap(dataStream, s -> alloc() .buffer() .writeBytes(s.getBytes(charset)))); }
@Override public Mono<Void> send(Publisher<WebSocketMessage> messages) { Flux<WebSocketFrame> frames = Flux.from(messages).map(this::toFrame); return getDelegate().getOutbound() .options(NettyPipeline.SendOptions::flushOnEach) .sendObject(frames) .then(); }