use of com.thetransactioncompany.jsonrpc2.client.JSONRPC2Session in project junit-plugin by kiwitcms.
the class RpcClient method logout.
public void logout() {
JSONRPC2Session mySession = prepareSession();
// Construct new request
int requestID = 1;
JSONRPC2Request request = new JSONRPC2Request(LOGOUT_METHOD, requestID);
// Send request
try {
getResponse(mySession.send(request));
} catch (JSONRPC2SessionException e) {
System.err.println(e.getMessage());
}
}
use of com.thetransactioncompany.jsonrpc2.client.JSONRPC2Session in project starcoin-java by starcoinorg.
the class JsonRPCClient method getObjectParseJackson.
/**
* 获取单个对象的接口(返回用Jackson封装,某些json格式用fastjson解析有问题,故此增加此方法)
*
* @param session
* @param method rpc接口的方法名
* @param params rpc接口的参数列表
* @param requestId 请求id
* @param clazz 返回对象的封装类
* @return
* @throws JSONRPC2SessionException
*/
protected T getObjectParseJackson(JSONRPC2Session session, String method, List<Object> params, int requestId, Class<T> clazz) throws JSONRPC2SessionException, IOException {
JSONRPC2Request request = new JSONRPC2Request(method, params, requestId);
JSONRPC2Response response = session.send(request);
if (response.indicatesSuccess()) {
Object result = response.getResult();
if (result != null) {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.readValue(result.toString(), clazz);
}
}
return null;
}
use of com.thetransactioncompany.jsonrpc2.client.JSONRPC2Session in project starcoin-java by starcoinorg.
the class JsonRPCClient method getSubObject.
/**
* 获取单个对象的属性值接口
*
* @param session
* @param method rpc接口的方法名
* @param params rpc接口的参数列表
* @param requestId 请求id
* @param clazz 返回对象的封装类
* @return
* @throws JSONRPC2SessionException
*/
protected T getSubObject(JSONRPC2Session session, String method, List<Object> params, int requestId, String subKey, Class<T> clazz) throws JSONRPC2SessionException {
JSONRPC2Request request = new JSONRPC2Request(method, params, requestId);
JSONRPC2Response response = session.send(request);
if (response.indicatesSuccess()) {
Object result = response.getResult();
if (result != null) {
JSONObject jb = JSON.parseObject(result.toString());
return jb.getObject(subKey, clazz);
}
}
return null;
}
Aggregations