/**
* Create RPC response protobuf from method invocation results.
*/
private SocketRpcProtos.Response createRpcResponse(Message response,
boolean callbackInvoked, SocketRpcController socketController) {
Builder responseBuilder = SocketRpcProtos.Response.newBuilder();
if (response != null) {
responseBuilder.setCallback(true).setResponseProto(
response.toByteString());
} else {
// Set whether callback was called (in case of async)
responseBuilder.setCallback(callbackInvoked);
}
if (socketController.failed()) {
responseBuilder.setError(socketController.errorText());
responseBuilder.setErrorReason(ErrorReason.RPC_FAILED);
}
return responseBuilder.build();
}