|
|
@@ -11,6 +11,7 @@ import com.nb.common.websocket.PubResponse;
|
|
|
import com.nb.common.websocket.TopicMessage;
|
|
|
import com.nb.common.websocket.filter.PubMsgFilter;
|
|
|
import com.nb.common.websocket.handler.TopicWrapper;
|
|
|
+import com.nb.common.websocket.msg.MessageResponse;
|
|
|
import com.nb.common.websocket.msg.MessagingRequest;
|
|
|
import com.nb.common.websocket.msg.handler.IMsgRequestHandler;
|
|
|
import com.nb.im.entity.ImMsgEntity;
|
|
|
@@ -58,15 +59,26 @@ public class PubMsgRequestHandler implements IMsgRequestHandler {
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void handler(MessagingRequest message, ChannelContext channelContext, TopicWrapper topicWrapper) throws JsonProcessingException {
|
|
|
+ public void handler(MessagingRequest message, ChannelContext channelContext, TopicWrapper topicWrapper) {
|
|
|
String param = topicWrapper.getParam();
|
|
|
if(CollectionUtil.isNotEmpty(msgFilters)){
|
|
|
boolean result = msgFilters.stream()
|
|
|
.allMatch(filter -> filter.doFilter(channelContext, message));
|
|
|
if(result){
|
|
|
- PubMsgInfo pubMsgInfo = objectMapper.readerFor(PubMsgInfo.class).readValue(String.valueOf(message.getPayload()));
|
|
|
- pubMsgInfo.setOperationType(MsgEnum.NORMAL);
|
|
|
- imUtils.send(param,topicWrapper,pubMsgInfo,channelContext,false);
|
|
|
+ try {
|
|
|
+ PubMsgInfo pubMsgInfo = objectMapper.readerFor(PubMsgInfo.class).readValue(String.valueOf(message.getPayload()));
|
|
|
+ pubMsgInfo.setOperationType(MsgEnum.NORMAL);
|
|
|
+ imUtils.send(param,topicWrapper,pubMsgInfo,channelContext,false);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("PubMsgRequestHandler.handler msg confront error,",e);
|
|
|
+ Tio.send(channelContext, WsResponse.fromText(JSONUtil.toJsonStr(
|
|
|
+ MessageResponse.of("im","im-result",
|
|
|
+ param,
|
|
|
+ PubResponse.fail(message.getKey(),"解析错误,发送失败"),
|
|
|
+ message.getKey())
|
|
|
+
|
|
|
+ ), WsPacket.CHARSET_NAME));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|