public async Task GetAddedNodeInfo() { Network network = new Network(); AddNodeInfoOM result = await network.GetAddedNodeInfo("192.168.1.177:4321"); Assert.IsNotNull(result); }
public static async Task <ApiResponse> GetAddedNodeInfo(string ipAddressWithPort) { ApiResponse response = new ApiResponse(); try { Network network = new Network(); AddNodeInfo node = new AddNodeInfo(); AddNodeInfoOM result = await network.GetAddedNodeInfo(ipAddressWithPort); if (result != null) { node.Address = result.Address; node.Connected = result.Connected; node.ConnectedTime = result.ConnectedTime; response.Result = Newtonsoft.Json.Linq.JToken.FromObject(node); } else { response.Result = null; } } catch (ApiCustomException ex) { Logger.Singleton.Error(ex.Message); response.Error = new ApiError(ex.ErrorCode, ex.Message); } catch (Exception ex) { Logger.Singleton.Error(ex.Message); response.Error = new ApiError(ex.HResult, ex.Message); } return(response); }
public async Task <AddNodeInfoOM> GetAddedNodeInfo(string ipAddressWithPort) { AuthenticationHeaderValue authHeaderValue = null; RpcClient client = new RpcClient(new Uri("http://localhost:5006"), authHeaderValue, null, null, "application/json"); RpcRequest request = RpcRequest.WithParameterList("GetAddedNodeInfo", new[] { ipAddressWithPort }, 1); RpcResponse response = await client.SendRequestAsync(request); if (response.HasError) { throw new ApiCustomException(response.Error.Code, response.Error.Message); } AddNodeInfoOM responseValue = response.GetResult <AddNodeInfoOM>(); return(responseValue); }