Search in sources :

Example 6 with ValueStack

use of com.roof.chain.api.ValueStack in project roof-im by madfroglx.

the class MessageTest method testSuccess.

@Test
public void testSuccess() throws Exception {
    online("bcd");
    online("abc");
    MessageRequest messageRequest = new MessageRequest();
    messageRequest.setRequestType("message");
    messageRequest.setToken("abc");
    messageRequest.setReceiver("abc");
    messageRequest.setType(ContentType.TXT);
    messageRequest.setClientType(ClientType.h5.name());
    messageRequest.setCreateTime(System.currentTimeMillis());
    messageRequest.setPayload("test");
    System.out.println(JSON.toJSONString(messageRequest));
    ValueStack valueStack = new GenericValueStack();
    valueStack.set(ImConstant.TEXT_MESSAGE, JSON.toJSONString(messageRequest));
    valueStack.set(ImConstant.CONNECT_ID, "1");
    JSONObject jsonObjectMessage = JSON.parseObject(JSON.toJSONString(messageRequest));
    valueStack.set(ImConstant.JSON_OBJECT_MESSAGE, jsonObjectMessage);
    enterChain.doChain(valueStack);
}
Also used : MessageRequest(org.roof.im.request.MessageRequest) 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 7 with ValueStack

use of com.roof.chain.api.ValueStack in project roof-im by madfroglx.

the class OfflineTest method testUserNotOnline.

@Test
public void testUserNotOnline() throws Exception {
    OfflineRequest offlineRequest = createRequest();
    ValueStack valueStack = createValueStack(offlineRequest);
    enterChain.doChain(valueStack);
}
Also used : OfflineRequest(org.roof.im.request.OfflineRequest) ValueStack(com.roof.chain.api.ValueStack) GenericValueStack(com.roof.chain.support.GenericValueStack) Test(org.junit.Test)

Example 8 with ValueStack

use of com.roof.chain.api.ValueStack 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 9 with ValueStack

use of com.roof.chain.api.ValueStack in project roof-im by madfroglx.

the class CloseSessionTest method testSuccess.

@Test
public void testSuccess() throws Exception {
    Session session = sessionManager.open("abc", "efg", 0, 99);
    CloseSessionRequest request = new CloseSessionRequest();
    request.setSessionId(session.getId());
    request.setRequestType(RequestType.closeSession.name());
    request.setToken("abc");
    ValueStack valueStack = getValueStack(request);
    enterChain.doChain(valueStack);
}
Also used : ValueStack(com.roof.chain.api.ValueStack) GenericValueStack(com.roof.chain.support.GenericValueStack) CloseSessionRequest(org.roof.im.request.CloseSessionRequest) Session(org.roof.im.session.Session) Test(org.junit.Test)

Example 10 with ValueStack

use of com.roof.chain.api.ValueStack 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)

Aggregations

ValueStack (com.roof.chain.api.ValueStack)13 GenericValueStack (com.roof.chain.support.GenericValueStack)13 JSONObject (com.alibaba.fastjson.JSONObject)7 Test (org.junit.Test)7 CloseSessionRequest (org.roof.im.request.CloseSessionRequest)2 MessageRequest (org.roof.im.request.MessageRequest)2 OfflineRequest (org.roof.im.request.OfflineRequest)2 ArrayList (java.util.ArrayList)1 OpenSessionRequest (org.roof.im.request.OpenSessionRequest)1 UserStateRequest (org.roof.im.request.UserStateRequest)1 Session (org.roof.im.session.Session)1 UserState (org.roof.im.user.UserState)1