Search in sources :

Example 1 with ValueStack

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

the class WebSocketRequestEnterPoint method receive.

@Override
public void receive(String sessionID, String message) {
    ValueStack valueStack = new GenericValueStack();
    valueStack.set(ImConstant.TEXT_MESSAGE, message);
    valueStack.set(ImConstant.CONNECT_ID, sessionID);
    JSONObject jsonObjectMessage;
    try {
        jsonObjectMessage = JSON.parseObject(message);
    } catch (Exception e) {
        LOGGER.error("input json error: {}", message);
        return;
    }
    valueStack.set(ImConstant.JSON_OBJECT_MESSAGE, jsonObjectMessage);
    try {
        enterChain.doChain(valueStack);
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}
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 2 with ValueStack

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

the class AbstractBlockingQueueRequestMessageDriveEnterPoint method subscribe.

@Override
public void subscribe(E message) {
    ValueStack valueStack = new GenericValueStack();
    valueStack.set(ImConstant.MESSAGE, message);
    try {
        chain.doChain(valueStack);
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}
Also used : ValueStack(com.roof.chain.api.ValueStack) GenericValueStack(com.roof.chain.support.GenericValueStack) GenericValueStack(com.roof.chain.support.GenericValueStack)

Example 3 with ValueStack

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

the class MessageRequestTest method testSuccess.

@Test
public void testSuccess() throws Exception {
    online("bcd");
    MessageRequest messageRequest = new MessageRequest();
    messageRequest.setRequestType("message");
    messageRequest.setToken("abc");
    messageRequest.setReceiver("bcd");
    messageRequest.setType(ContentType.TXT);
    messageRequest.setClientType(ClientType.h5.name());
    messageRequest.setCreateTime(System.currentTimeMillis());
    messageRequest.setPayload("test");
    ValueStack valueStack = new GenericValueStack();
    valueStack.set(ImConstant.TEXT_MESSAGE, JSON.toJSONString(messageRequest));
    valueStack.set(ImConstant.CONNECT_ID, "1");
    valueStack.set("messageRequest", messageRequest);
    messageRequestChain.doChain(valueStack);
}
Also used : MessageRequest(org.roof.im.request.MessageRequest) ValueStack(com.roof.chain.api.ValueStack) GenericValueStack(com.roof.chain.support.GenericValueStack) GenericValueStack(com.roof.chain.support.GenericValueStack) Test(org.junit.Test)

Example 4 with ValueStack

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

the class RequestTest method online.

public void online(String token) throws Exception {
    UserStateRequest userStateRequest = new UserStateRequest();
    userStateRequest.setClientType(ClientType.h5.name());
    userStateRequest.setRequestType("online");
    userStateRequest.setToken(token);
    ValueStack valueStack = new GenericValueStack();
    System.out.println(JSON.toJSONString(userStateRequest));
    valueStack.set(ImConstant.TEXT_MESSAGE, JSON.toJSONString(userStateRequest));
    valueStack.set(ImConstant.CONNECT_ID, "1");
    JSONObject jsonObjectMessage = JSON.parseObject(JSON.toJSONString(userStateRequest));
    valueStack.set(ImConstant.JSON_OBJECT_MESSAGE, jsonObjectMessage);
    enterChain.doChain(valueStack);
}
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) UserStateRequest(org.roof.im.request.UserStateRequest)

Example 5 with ValueStack

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

the class CloseSessionTest method testSessionNotExists.

@Test
public void testSessionNotExists() throws Exception {
    CloseSessionRequest request = new CloseSessionRequest();
    request.setSessionId(123);
    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) Test(org.junit.Test)

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