use of com.alibaba.nacos.api.remote.response.ConnectResetResponse in project nacos by alibaba.
the class GrpcBiStreamRequestAcceptorTest method testConnectionSetupRequest.
@Test
public void testConnectionSetupRequest() {
StreamObserver<Payload> streamObserver = new StreamObserver<Payload>() {
@Override
public void onNext(Payload payload) {
System.out.println("Receive data from server, data: " + payload);
Assert.assertNotNull(payload);
ConnectResetRequest connectResetRequest = (ConnectResetRequest) GrpcUtils.parse(payload);
Response response = new ConnectResetResponse();
response.setRequestId(connectResetRequest.getRequestId());
Payload res = GrpcUtils.convert(response);
payloadStreamObserver.onNext(res);
payloadStreamObserver.onCompleted();
}
@Override
public void onError(Throwable throwable) {
Assert.fail(throwable.getMessage());
}
@Override
public void onCompleted() {
System.out.println("complete");
}
};
payloadStreamObserver = streamStub.requestBiStream(streamObserver);
RequestMeta metadata = new RequestMeta();
metadata.setClientIp("127.0.0.1");
metadata.setConnectionId(connectId);
ConnectionSetupRequest connectionSetupRequest = new ConnectionSetupRequest();
connectionSetupRequest.setRequestId(requestId);
connectionSetupRequest.setClientVersion("2.0.3");
Payload payload = GrpcUtils.convert(connectionSetupRequest, metadata);
payloadStreamObserver.onNext(payload);
}
Aggregations