本文整理汇总了Java中io.vertx.core.streams.Pump.pump方法的典型用法代码示例。如果您正苦于以下问题:Java Pump.pump方法的具体用法?Java Pump.pump怎么用?Java Pump.pump使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.streams.Pump
的用法示例。
在下文中一共展示了Pump.pump方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FullDuplexMuxChannel
import io.vertx.core.streams.Pump; //导入方法依赖的package包/类
public FullDuplexMuxChannel(MessageStream messageStream, StreamMux outStreamMux) {
this.messageStream = messageStream;
this.outStreamMux = outStreamMux;
outStreamMux.writeCompleteHandler(messageStream.getWriteCompleteHandler());
final InPipeline inPipeline = messageStream.getInPipeline();
final OutPipeline outPipeline = messageStream.getOutPipeline();
inToOutPump = Pump.pump(inPipeline, outStreamMux);
outToInPump = Pump.pump(outStreamMux, outPipeline);
inPipeline.endHandler(v -> {
if (endHandler != null) endHandler.handle(null);
doStop();
});
inPipeline.exceptionHandler(t -> {
logger.error("Error processing the InPipeline. Usually an error splitting or decoding.", t);
if (t instanceof PacketParsingException) {
PacketParsingException exception = (PacketParsingException)t;
PipelinePack data = exception.getPipelinePack();
outPipeline.write(data);
}
doStop();
inPipeline.close();
});
outStreamMux.exceptionHandler(t -> {
logger.error("Error in mux. Shutting down channel and closing the Input pipeline.", t);
doStop();
inPipeline.close();
});
}
示例2: initSendingPump
import io.vertx.core.streams.Pump; //导入方法依赖的package包/类
private void initSendingPump() {
_wsWriteStream = new WebsocketWriteStream(_socket, _maxFrameSize);
_wsSendQueueStream = new WebsocketSendQueueStream();
_wsSendQueueStream.streamEndedHandler(v -> _wsWriteStream.finishCurrentMessage());
_wsSendQueueStream.streamStartedHandler(_wsWriteStream::setDataFormat);
_wsSendingPump = Pump.pump(_wsSendQueueStream, _wsWriteStream);
_wsSendingPump.start();
}
示例3: toReadStream
import io.vertx.core.streams.Pump; //导入方法依赖的package包/类
public void toReadStream(io.vertx.rxjava.core.Vertx vertx, HttpServerResponse response) {
Observable<Buffer> observable = getObservable();
ReadStream<Buffer> readStream = RxHelper.toReadStream(observable);
Pump pump = Pump.pump(readStream, response);
pump.start();
}
示例4: toReadStream
import io.vertx.core.streams.Pump; //导入方法依赖的package包/类
public void toReadStream(HttpServerResponse response) {
Flowable<Buffer> observable = getFlowable();
ReadStream<Buffer> readStream = FlowableHelper.toReadStream(observable);
Pump pump = Pump.pump(readStream, response);
pump.start();
}
示例5: example1
import io.vertx.core.streams.Pump; //导入方法依赖的package包/类
public void example1(HttpServerResponse response, Publisher<Buffer> otherPublisher) {
ReactiveReadStream<Buffer> rrs = ReactiveReadStream.readStream();
// Subscribe the read stream to the publisher
otherPublisher.subscribe(rrs);
// Pump from the read stream to the http response
Pump pump = Pump.pump(rrs, response);
pump.start();
}
示例6: example2
import io.vertx.core.streams.Pump; //导入方法依赖的package包/类
public void example2(Vertx vertx, HttpServerRequest request, Subscriber<Buffer> otherSubscriber) {
ReactiveWriteStream<Buffer> rws = ReactiveWriteStream.writeStream(vertx);
// Subscribe the other subscriber to the write stream
rws.subscribe(otherSubscriber);
// Pump the http request to the write stream
Pump pump = Pump.pump(request, rws);
pump.start();
}