|
32 | 32 | import org.fisco.bcos.sdk.config.ConfigOption; |
33 | 33 | import org.fisco.bcos.sdk.crypto.CryptoSuite; |
34 | 34 | import org.fisco.bcos.sdk.jni.BcosSDKJniObj; |
| 35 | +import org.fisco.bcos.sdk.jni.rpc.RpcCallback; |
35 | 36 | import org.fisco.bcos.sdk.jni.rpc.RpcJniObj; |
36 | 37 | import org.fisco.bcos.sdk.model.CryptoType; |
37 | 38 | import org.fisco.bcos.sdk.model.JsonRpcResponse; |
@@ -895,21 +896,65 @@ public void getGroupListAsync(RespCallback<BcosGroupList> callback) { |
895 | 896 |
|
896 | 897 | @Override |
897 | 898 | public BcosGroupInfo getGroupInfo() { |
898 | | - return this.callRemoteMethod( |
899 | | - this.groupID, |
900 | | - "", |
901 | | - new JsonRpcRequest(JsonRpcMethods.GET_GROUP_INFO, Arrays.asList(groupID)), |
902 | | - BcosGroupInfo.class); |
| 899 | + try { |
| 900 | + CompletableFuture<Response> future = new CompletableFuture<>(); |
| 901 | + |
| 902 | + this.rpcJniObj.getGroupInfo( |
| 903 | + groupID, |
| 904 | + (resp) -> { |
| 905 | + Response response = new Response(); |
| 906 | + response.setErrorCode(resp.getErrorCode()); |
| 907 | + response.setErrorMessage(resp.getErrorMessage()); |
| 908 | + response.setContent(resp.getData()); |
| 909 | + |
| 910 | + if (logger.isDebugEnabled()) { |
| 911 | + logger.debug("getGroupInfo onResponse: {}", response); |
| 912 | + } |
| 913 | + |
| 914 | + future.complete(response); |
| 915 | + }); |
| 916 | + Response response = future.get(); |
| 917 | + return this.parseResponseIntoJsonRpcResponse( |
| 918 | + new JsonRpcRequest(JsonRpcMethods.GET_GROUP_INFO, Arrays.asList(groupID)), |
| 919 | + response, |
| 920 | + BcosGroupInfo.class); |
| 921 | + } catch (InterruptedException | ExecutionException e) { |
| 922 | + logger.error("e: ", e); |
| 923 | + throw new ClientException( |
| 924 | + "getGroupInfo failed for decode the message exception, error message:" |
| 925 | + + e.getMessage(), |
| 926 | + e); |
| 927 | + } |
903 | 928 | } |
904 | 929 |
|
905 | 930 | @Override |
906 | 931 | public void getGroupInfoAsync(RespCallback<BcosGroupInfo> callback) { |
907 | | - this.asyncCallRemoteMethod( |
| 932 | + rpcJniObj.getGroupInfo( |
908 | 933 | this.groupID, |
909 | | - "", |
910 | | - new JsonRpcRequest(JsonRpcMethods.GET_GROUP_INFO, Arrays.asList(groupID)), |
911 | | - BcosGroupInfo.class, |
912 | | - callback); |
| 934 | + new RpcCallback() { |
| 935 | + @Override |
| 936 | + public void onResponse(org.fisco.bcos.sdk.jni.common.Response resp) { |
| 937 | + |
| 938 | + Response response = new Response(); |
| 939 | + response.setErrorCode(resp.getErrorCode()); |
| 940 | + response.setErrorMessage(resp.getErrorMessage()); |
| 941 | + response.setContent(resp.getData()); |
| 942 | + |
| 943 | + ResponseCallback responseCallback = |
| 944 | + createResponseCallback( |
| 945 | + new JsonRpcRequest( |
| 946 | + JsonRpcMethods.GET_GROUP_INFO, |
| 947 | + Arrays.asList(groupID)), |
| 948 | + BcosGroupInfo.class, |
| 949 | + callback); |
| 950 | + |
| 951 | + if (logger.isDebugEnabled()) { |
| 952 | + logger.debug("getGroupInfo onResponse: {}", response); |
| 953 | + } |
| 954 | + |
| 955 | + responseCallback.onResponse(response); |
| 956 | + } |
| 957 | + }); |
913 | 958 | } |
914 | 959 |
|
915 | 960 | @Override |
|
0 commit comments