本文整理了Java中io.rsocket.Frame.getType()
方法的一些代码示例,展示了Frame.getType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Frame.getType()
方法的具体详情如下:
包路径:io.rsocket.Frame
类名称:Frame
方法名:getType
[英]Return frame FrameType
[中]返回帧帧类型
代码示例来源:origin: rsocket/rsocket-java
public static void ensureFrameType(final FrameType frameType, final Frame frame) {
final FrameType typeInFrame = frame.getType();
if (typeInFrame != frameType) {
throw new AssertionError("expected " + frameType + ", but saw" + typeInFrame);
}
}
代码示例来源:origin: rsocket/rsocket-java
public static boolean isTracked(Frame frame) {
return isTracked(frame.getType());
}
代码示例来源:origin: rsocket/rsocket-java
public static int initialRequestN(final Frame frame) {
final FrameType type = frame.getType();
int result;
if (!type.isRequestType()) {
throw new AssertionError("expected request type, but saw " + type.name());
}
switch (frame.getType()) {
case REQUEST_RESPONSE:
result = 1;
break;
case REQUEST_FNF:
case METADATA_PUSH:
result = 0;
break;
default:
result = RequestFrameFlyweight.initialRequestN(frame.content);
break;
}
return result;
}
代码示例来源:origin: rsocket/rsocket-java
@Test(timeout = 2_000)
public void testRequestReplyWithCancel() {
Mono<Payload> response = rule.socket.requestResponse(EmptyPayload.INSTANCE);
try {
response.block(Duration.ofMillis(100));
} catch (IllegalStateException ise) {
}
List<Frame> sent =
rule.connection
.getSent()
.stream()
.filter(f -> f.getType() != KEEPALIVE)
.collect(Collectors.toList());
assertThat(
"Unexpected frame sent on the connection.", sent.get(0).getType(), is(REQUEST_RESPONSE));
assertThat("Unexpected frame sent on the connection.", sent.get(1).getType(), is(CANCEL));
}
代码示例来源:origin: rsocket/rsocket-java
@Test(timeout = 2000)
@Ignore
public void testHandlerEmitsError() throws Exception {
final int streamId = 4;
rule.sendRequest(streamId, FrameType.REQUEST_STREAM);
assertThat("Unexpected error.", rule.errors, is(empty()));
assertThat(
"Unexpected frame sent.", rule.connection.awaitSend().getType(), is(FrameType.ERROR));
}
代码示例来源:origin: rsocket/rsocket-java
@Test(timeout = 2_000)
public void testKeepAlive() throws Exception {
assertThat("Unexpected frame sent.", rule.connection.awaitSend().getType(), is(KEEPALIVE));
}
代码示例来源:origin: rsocket/rsocket-java
private void handleIncomingFrames(Frame frame) {
try {
int streamId = frame.getStreamId();
FrameType type = frame.getType();
if (streamId == 0) {
handleStreamZero(type, frame);
} else {
handleFrame(streamId, type, frame);
}
} finally {
frame.release();
}
}
代码示例来源:origin: rsocket/rsocket-java
public int getStreamIdForRequestType(FrameType expectedFrameType) {
assertThat("Unexpected frames sent.", connection.getSent(), hasSize(greaterThanOrEqualTo(1)));
List<FrameType> framesFound = new ArrayList<>();
for (Frame frame : connection.getSent()) {
if (frame.getType() == expectedFrameType) {
return frame.getStreamId();
}
framesFound.add(frame.getType());
}
throw new AssertionError(
"No frames sent with frame type: "
+ expectedFrameType
+ ", frames found: "
+ framesFound);
}
}
代码示例来源:origin: rsocket/rsocket-java
@Test(timeout = 2000)
@Ignore
public void testHandleResponseFrameNoError() throws Exception {
final int streamId = 4;
rule.connection.clearSendReceiveBuffers();
rule.sendRequest(streamId, FrameType.REQUEST_RESPONSE);
Collection<Subscriber<Frame>> sendSubscribers = rule.connection.getSendSubscribers();
assertThat("Request not sent.", sendSubscribers, hasSize(1));
assertThat("Unexpected error.", rule.errors, is(empty()));
Subscriber<Frame> sendSub = sendSubscribers.iterator().next();
assertThat(
"Unexpected frame sent.",
rule.connection.awaitSend().getType(),
anyOf(is(FrameType.COMPLETE), is(FrameType.NEXT_COMPLETE)));
}
代码示例来源: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: rsocket/rsocket-java
@Test(timeout = 2000)
@Ignore
public void testHandleKeepAlive() throws Exception {
rule.connection.addToReceivedBuffer(Frame.Keepalive.from(Unpooled.EMPTY_BUFFER, true));
Frame sent = rule.connection.awaitSend();
assertThat("Unexpected frame sent.", sent.getType(), is(FrameType.KEEPALIVE));
/*Keep alive ack must not have respond flag else, it will result in infinite ping-pong of keep alive frames.*/
assertThat(
"Unexpected keep-alive frame respond flag.",
Frame.Keepalive.hasRespondFlag(sent),
is(false));
}
代码示例来源:origin: rsocket/rsocket-java
@Test
void responderRejectSetup() {
SingleConnectionTransport transport = new SingleConnectionTransport();
String errorMsg = "error";
RejectingAcceptor acceptor = new RejectingAcceptor(errorMsg);
RSocketFactory.receive().acceptor(acceptor).transport(transport).start().block();
transport.connect();
Frame sentFrame = transport.awaitSent();
assertThat(sentFrame.getType()).isEqualTo(FrameType.ERROR);
RuntimeException error = Exceptions.from(sentFrame);
assertThat(errorMsg).isEqualTo(error.getMessage());
assertThat(error).isInstanceOf(RejectedSetupException.class);
RSocket acceptorSender = acceptor.senderRSocket().block();
assertThat(acceptorSender.isDisposed()).isTrue();
}
代码示例来源:origin: rsocket/rsocket-java
int streamId = frame.getStreamId();
Subscriber<Payload> receiver;
switch (frame.getType()) {
case REQUEST_FNF:
handleFireAndForget(streamId, fireAndForget(frameDecoder.apply(frame)));
streamId,
new IllegalStateException(
"ServerRSocket: Unexpected frame type: " + frame.getType()));
break;
代码示例来源:origin: io.rsocket/rsocket-core
public static void ensureFrameType(final FrameType frameType, final Frame frame) {
final FrameType typeInFrame = frame.getType();
if (typeInFrame != frameType) {
throw new AssertionError("expected " + frameType + ", but saw" + typeInFrame);
}
}
代码示例来源:origin: rsocket/rsocket-java
@Test
void clientRequesterRespondsToKeepAlives() {
TestData testData = requester(100, 700, 3).get();
TestDuplexConnection connection = testData.connection();
Mono.delay(Duration.ofMillis(100))
.subscribe(
l -> connection.addToReceivedBuffer(Frame.Keepalive.from(Unpooled.EMPTY_BUFFER, true)));
Mono<Void> keepAliveResponse =
Flux.from(connection.getSentAsPublisher())
.filter(f -> f.getType() == FrameType.KEEPALIVE && !Frame.Keepalive.hasRespondFlag(f))
.next()
.then();
StepVerifier.create(keepAliveResponse).expectComplete().verify(Duration.ofSeconds(5));
}
代码示例来源:origin: io.rsocket/rsocket-core
public static boolean isTracked(Frame frame) {
return isTracked(frame.getType());
}
代码示例来源:origin: rsocket/rsocket-java
@Override
public void accept(Frame frame) {
FrameType frameType = frame.getType();
代码示例来源:origin: io.rsocket/rsocket-core
public static int initialRequestN(final Frame frame) {
final FrameType type = frame.getType();
int result;
if (!type.isRequestType()) {
throw new AssertionError("expected request type, but saw " + type.name());
}
switch (frame.getType()) {
case REQUEST_RESPONSE:
result = 1;
break;
case REQUEST_FNF:
case METADATA_PUSH:
result = 0;
break;
default:
result = RequestFrameFlyweight.initialRequestN(frame.content);
break;
}
return result;
}
代码示例来源:origin: io.rsocket/rsocket-core
private void handleIncomingFrames(Frame frame) {
try {
int streamId = frame.getStreamId();
FrameType type = frame.getType();
if (streamId == 0) {
handleStreamZero(type, frame);
} else {
handleFrame(streamId, type, frame);
}
} finally {
frame.release();
}
}
代码示例来源:origin: io.rsocket/rsocket-core
int streamId = frame.getStreamId();
Subscriber<Payload> receiver;
switch (frame.getType()) {
case REQUEST_FNF:
handleFireAndForget(streamId, fireAndForget(frameDecoder.apply(frame)));
streamId,
new IllegalStateException(
"ServerRSocket: Unexpected frame type: " + frame.getType()));
break;
内容来源于网络,如有侵权,请联系作者删除!