use of com.roof.chain.support.GenericValueStack in project roof-im by madfroglx.
the class OfflineTest method createValueStack.
private ValueStack createValueStack(OfflineRequest offlineRequest) {
ValueStack valueStack = new GenericValueStack();
valueStack.set(ImConstant.TEXT_MESSAGE, JSON.toJSONString(offlineRequest));
valueStack.set(ImConstant.CONNECT_ID, "1");
JSONObject jsonObjectMessage = JSON.parseObject(JSON.toJSONString(offlineRequest));
valueStack.set(ImConstant.JSON_OBJECT_MESSAGE, jsonObjectMessage);
return valueStack;
}
use of com.roof.chain.support.GenericValueStack in project roof-im by madfroglx.
the class CloseSessionTest method getValueStack.
private ValueStack getValueStack(CloseSessionRequest request) {
ValueStack valueStack = new GenericValueStack();
valueStack.set(ImConstant.TEXT_MESSAGE, JSON.toJSONString(request));
JSONObject jsonObjectMessage = JSON.parseObject(JSON.toJSONString(request));
valueStack.set(ImConstant.JSON_OBJECT_MESSAGE, jsonObjectMessage);
return valueStack;
}
use of com.roof.chain.support.GenericValueStack in project roof-im by madfroglx.
the class OpenSessionTest method testSuccess.
@Test
public void testSuccess() throws Exception {
OpenSessionRequest openSessionRequest = new OpenSessionRequest();
openSessionRequest.setSender("abc");
openSessionRequest.setReceiver("def");
openSessionRequest.setToken("ab");
openSessionRequest.setRequestType(RequestType.openSession.name());
ValueStack valueStack = new GenericValueStack();
valueStack.set(ImConstant.TEXT_MESSAGE, JSON.toJSONString(openSessionRequest));
JSONObject jsonObjectMessage = JSON.parseObject(JSON.toJSONString(openSessionRequest));
valueStack.set(ImConstant.JSON_OBJECT_MESSAGE, jsonObjectMessage);
enterChain.doChain(valueStack);
}
use of com.roof.chain.support.GenericValueStack in project roof-im by madfroglx.
the class AbstractChainController method doChain.
protected Object doChain(@RequestBody String request, Logger logger) {
ValueStack valueStack = new GenericValueStack();
valueStack.set(ImConstant.TEXT_MESSAGE, request);
JSONObject jsonObjectMessage;
try {
jsonObjectMessage = JSON.parseObject(request);
} catch (Exception e) {
logger.error("input json error: {}", request);
return new Response<>(Response.ERROR, "json format error");
}
valueStack.set(ImConstant.JSON_OBJECT_MESSAGE, jsonObjectMessage);
try {
enterChain.doChain(valueStack);
return valueStack.get(ImConstant.RESPONSE);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new Response<>(Response.ERROR, e.getMessage());
}
}
Aggregations