use of com.roof.chain.api.ValueStack in project roof-im by madfroglx.
the class OfflineTest method testSuccess.
@Test
public void testSuccess() throws Exception {
List<UserState> states = new ArrayList<>();
UserState userState = new UserState();
userState.setConnectId("1");
userState.setClientType(ClientType.h5.name());
userState.setUsername("abc");
userState.setServerName(serverNameBuilder.getName());
states.add(userState);
UserState userState2 = new UserState();
userState2.setConnectId("1");
userState2.setClientType("applet");
userState2.setUsername("abc");
userState2.setServerName(serverNameBuilder.getName());
states.add(userState2);
userStateService.online("abc", states);
OfflineRequest offlineRequest = createRequest();
ValueStack valueStack = createValueStack(offlineRequest);
enterChain.doChain(valueStack);
}
use of com.roof.chain.api.ValueStack 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.api.ValueStack 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