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);
}
}
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);
}
}
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);
}
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);
}
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);
}
Aggregations