本文整理了Java中io.rsocket.Frame.content()
方法的一些代码示例,展示了Frame.content()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Frame.content()
方法的具体详情如下:
包路径:io.rsocket.Frame
类名称:Frame
方法名:content
[英]Return the content which is held by this Frame.
[中]返回此框架所包含的内容。
代码示例来源:origin: rsocket/rsocket-java
public static int offset(Frame frame) {
int length = frame.content().readableBytes();
if (length < FrameHeaderFlyweight.FRAME_HEADER_LENGTH) {
throw new IllegalStateException("invalid frame");
}
return length - FrameHeaderFlyweight.FRAME_LENGTH_SIZE;
}
}
代码示例来源:origin: rsocket/rsocket-java
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Frame)) {
return false;
}
final Frame frame = (Frame) o;
return content.equals(frame.content());
}
代码示例来源:origin: rsocket/rsocket-java
@Override
public int keepAliveMaxLifetime() {
return SetupFrameFlyweight.maxLifetime(setupFrame.content());
}
代码示例来源:origin: rsocket/rsocket-java
@Override
public int keepAliveInterval() {
return SetupFrameFlyweight.keepaliveInterval(setupFrame.content());
}
代码示例来源:origin: rsocket/rsocket-java
private BinaryWebSocketFrame toBinaryWebSocketFrame(Frame frame) {
return new BinaryWebSocketFrame(frame.content().skipBytes(FRAME_LENGTH_SIZE).retain());
}
}
代码示例来源:origin: rsocket/rsocket-java
@Override
public Mono<Void> send(Publisher<Frame> frames) {
return Flux.from(frames)
.transform(
frameFlux -> {
if (frameFlux instanceof Fuseable.QueueSubscription) {
Fuseable.QueueSubscription<Frame> queueSubscription =
(Fuseable.QueueSubscription<Frame>) frameFlux;
queueSubscription.requestFusion(Fuseable.ASYNC);
return new SendPublisher<>(
queueSubscription,
frameFlux,
connection.channel(),
frame -> frame.content().retain(),
ByteBuf::readableBytes);
} else {
return new SendPublisher<>(
frameFlux,
connection.channel(),
frame -> frame.content().retain(),
ByteBuf::readableBytes);
}
})
.then();
}
}
代码示例来源:origin: rsocket/rsocket-java
/**
* Returns a {@link Tuple2} of the stream id, and the frame. This strips the frame length and
* stream id header from the abstraction leaking frame.
*
* @param abstractionLeakingFrame the abstraction leaking frame
* @return a {@link Tuple2} of the stream id, and the frame
* @throws NullPointerException if {@code abstractionLeakingFrame} is {@code null}
*/
public static Tuple2<Integer, io.rsocket.framing.Frame> fromAbstractionLeakingFrame(
Frame abstractionLeakingFrame) {
Objects.requireNonNull(abstractionLeakingFrame, "abstractionLeakingFrame must not be null");
FrameLengthFrame frameLengthFrame = null;
StreamIdFrame streamIdFrame = null;
try {
frameLengthFrame = createFrameLengthFrame(abstractionLeakingFrame.content());
streamIdFrame =
frameLengthFrame.mapFrameWithoutFrameLength(StreamIdFrame::createStreamIdFrame);
io.rsocket.framing.Frame frame =
streamIdFrame.mapFrameWithoutStreamId(FrameFactory::createFrame);
return Tuples.of(streamIdFrame.getStreamId(), frame);
} finally {
disposeQuietly(frameLengthFrame, streamIdFrame);
release(abstractionLeakingFrame);
}
}
代码示例来源:origin: rsocket/rsocket-java
@Test(timeout = 2_000)
public void testStreamInitialN() {
Flux<Payload> stream = rule.socket.requestStream(EmptyPayload.INSTANCE);
BaseSubscriber<Payload> subscriber =
new BaseSubscriber<Payload>() {
@Override
protected void hookOnSubscribe(Subscription subscription) {
// don't request here
// subscription.request(3);
}
};
stream.subscribe(subscriber);
subscriber.request(5);
List<Frame> sent =
rule.connection
.getSent()
.stream()
.filter(f -> f.getType() != KEEPALIVE)
.collect(Collectors.toList());
assertThat("sent frame count", sent.size(), is(1));
Frame f = sent.get(0);
assertThat("initial frame", f.getType(), is(REQUEST_STREAM));
assertThat("initial request n", RequestFrameFlyweight.initialRequestN(f.content()), is(5));
}
代码示例来源:origin: io.rsocket/rsocket-core
public static int offset(Frame frame) {
int length = frame.content().readableBytes();
if (length < FrameHeaderFlyweight.FRAME_HEADER_LENGTH) {
throw new IllegalStateException("invalid frame");
}
return length - FrameHeaderFlyweight.FRAME_LENGTH_SIZE;
}
}
代码示例来源:origin: io.rsocket/rsocket-core
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Frame)) {
return false;
}
final Frame frame = (Frame) o;
return content.equals(frame.content());
}
代码示例来源:origin: io.rsocket/rsocket-core
@Override
public int keepAliveMaxLifetime() {
return SetupFrameFlyweight.maxLifetime(setupFrame.content());
}
代码示例来源:origin: io.rsocket/rsocket-core
@Override
public int keepAliveInterval() {
return SetupFrameFlyweight.keepaliveInterval(setupFrame.content());
}
代码示例来源:origin: io.rsocket/rsocket-transport-netty
private BinaryWebSocketFrame toBinaryWebSocketFrame(Frame frame) {
return new BinaryWebSocketFrame(frame.content().skipBytes(FRAME_LENGTH_SIZE).retain());
}
}
代码示例来源:origin: io.rsocket/rsocket-transport-netty
@Override
public Mono<Void> send(Publisher<Frame> frames) {
return Flux.from(frames)
.transform(
frameFlux -> {
if (frameFlux instanceof Fuseable.QueueSubscription) {
Fuseable.QueueSubscription<Frame> queueSubscription =
(Fuseable.QueueSubscription<Frame>) frameFlux;
queueSubscription.requestFusion(Fuseable.ASYNC);
return new SendPublisher<>(
queueSubscription,
frameFlux,
connection.channel(),
frame -> frame.content().retain(),
ByteBuf::readableBytes);
} else {
return new SendPublisher<>(
frameFlux,
connection.channel(),
frame -> frame.content().retain(),
ByteBuf::readableBytes);
}
})
.then();
}
}
代码示例来源:origin: io.rsocket/rsocket-core
/**
* Returns a {@link Tuple2} of the stream id, and the frame. This strips the frame length and
* stream id header from the abstraction leaking frame.
*
* @param abstractionLeakingFrame the abstraction leaking frame
* @return a {@link Tuple2} of the stream id, and the frame
* @throws NullPointerException if {@code abstractionLeakingFrame} is {@code null}
*/
public static Tuple2<Integer, io.rsocket.framing.Frame> fromAbstractionLeakingFrame(
Frame abstractionLeakingFrame) {
Objects.requireNonNull(abstractionLeakingFrame, "abstractionLeakingFrame must not be null");
FrameLengthFrame frameLengthFrame = null;
StreamIdFrame streamIdFrame = null;
try {
frameLengthFrame = createFrameLengthFrame(abstractionLeakingFrame.content());
streamIdFrame =
frameLengthFrame.mapFrameWithoutFrameLength(StreamIdFrame::createStreamIdFrame);
io.rsocket.framing.Frame frame =
streamIdFrame.mapFrameWithoutStreamId(FrameFactory::createFrame);
return Tuples.of(streamIdFrame.getStreamId(), frame);
} finally {
disposeQuietly(frameLengthFrame, streamIdFrame);
release(abstractionLeakingFrame);
}
}
内容来源于网络,如有侵权,请联系作者删除!