Search in sources :

Example 6 with GenericValueStack

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;
}
Also used : ValueStack(com.roof.chain.api.ValueStack) GenericValueStack(com.roof.chain.support.GenericValueStack) JSONObject(com.alibaba.fastjson.JSONObject) GenericValueStack(com.roof.chain.support.GenericValueStack)

Example 7 with GenericValueStack

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;
}
Also used : ValueStack(com.roof.chain.api.ValueStack) GenericValueStack(com.roof.chain.support.GenericValueStack) JSONObject(com.alibaba.fastjson.JSONObject) GenericValueStack(com.roof.chain.support.GenericValueStack)

Example 8 with GenericValueStack

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);
}
Also used : OpenSessionRequest(org.roof.im.request.OpenSessionRequest) ValueStack(com.roof.chain.api.ValueStack) GenericValueStack(com.roof.chain.support.GenericValueStack) JSONObject(com.alibaba.fastjson.JSONObject) GenericValueStack(com.roof.chain.support.GenericValueStack) Test(org.junit.Test)

Example 9 with GenericValueStack

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());
    }
}
Also used : GenericValueStack(com.roof.chain.support.GenericValueStack) ValueStack(com.roof.chain.api.ValueStack) JSONObject(com.alibaba.fastjson.JSONObject) GenericValueStack(com.roof.chain.support.GenericValueStack)

Aggregations

ValueStack (com.roof.chain.api.ValueStack)9 GenericValueStack (com.roof.chain.support.GenericValueStack)9 JSONObject (com.alibaba.fastjson.JSONObject)7 Test (org.junit.Test)3 MessageRequest (org.roof.im.request.MessageRequest)2 OpenSessionRequest (org.roof.im.request.OpenSessionRequest)1 UserStateRequest (org.roof.im.request.UserStateRequest)1