正在显示
3 个修改的文件
包含
29 行增加
和
5 行删除
| 1 | package com.crossoverjie.cim.client.config; | 1 | package com.crossoverjie.cim.client.config; |
| 2 | 2 | ||
| 3 | import com.crossoverjie.cim.client.handle.MsgHandleCaller; | 3 | import com.crossoverjie.cim.client.handle.MsgHandleCaller; |
| 4 | +import com.crossoverjie.cim.client.service.impl.MsgCallBackListener; | ||
| 4 | import com.crossoverjie.cim.common.constant.Constants; | 5 | import com.crossoverjie.cim.common.constant.Constants; |
| 5 | import com.crossoverjie.cim.common.protocol.CIMRequestProto; | 6 | import com.crossoverjie.cim.common.protocol.CIMRequestProto; |
| 6 | import com.google.common.util.concurrent.ThreadFactoryBuilder; | 7 | import com.google.common.util.concurrent.ThreadFactoryBuilder; |
| @@ -87,9 +88,7 @@ public class BeanConfig { | @@ -87,9 +88,7 @@ public class BeanConfig { | ||
| 87 | */ | 88 | */ |
| 88 | @Bean | 89 | @Bean |
| 89 | public MsgHandleCaller buildCaller(){ | 90 | public MsgHandleCaller buildCaller(){ |
| 90 | - MsgHandleCaller caller = new MsgHandleCaller(msg -> { | ||
| 91 | - //处理业务逻辑,或者自定义实现接口 | ||
| 92 | - }) ; | 91 | + MsgHandleCaller caller = new MsgHandleCaller(new MsgCallBackListener()) ; |
| 93 | 92 | ||
| 94 | return caller ; | 93 | return caller ; |
| 95 | } | 94 | } |
| @@ -72,8 +72,6 @@ public class AsyncMsgLogger implements MsgLogger { | @@ -72,8 +72,6 @@ public class AsyncMsgLogger implements MsgLogger { | ||
| 72 | 72 | ||
| 73 | private void writeLog(String msg) { | 73 | private void writeLog(String msg) { |
| 74 | 74 | ||
| 75 | - msg = appConfiguration.getUserName() + ":" + "【" + msg + "】"; | ||
| 76 | - | ||
| 77 | LocalDate today = LocalDate.now(); | 75 | LocalDate today = LocalDate.now(); |
| 78 | int year = today.getYear(); | 76 | int year = today.getYear(); |
| 79 | int month = today.getMonthValue(); | 77 | int month = today.getMonthValue(); |
cim-client/src/main/java/com/crossoverjie/cim/client/service/impl/MsgCallBackListener.java
0 → 100644
| 1 | +package com.crossoverjie.cim.client.service.impl; | ||
| 2 | + | ||
| 3 | +import com.crossoverjie.cim.client.service.CustomMsgHandleListener; | ||
| 4 | +import com.crossoverjie.cim.client.service.MsgLogger; | ||
| 5 | +import com.crossoverjie.cim.client.util.SpringBeanFactory; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * Function:自定义收到消息回调 | ||
| 9 | + * | ||
| 10 | + * @author crossoverJie | ||
| 11 | + * Date: 2019/1/6 17:49 | ||
| 12 | + * @since JDK 1.8 | ||
| 13 | + */ | ||
| 14 | +public class MsgCallBackListener implements CustomMsgHandleListener { | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + private MsgLogger msgLogger ; | ||
| 18 | + | ||
| 19 | + public MsgCallBackListener() { | ||
| 20 | + this.msgLogger = SpringBeanFactory.getBean(MsgLogger.class) ; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + @Override | ||
| 24 | + public void handle(String msg) { | ||
| 25 | + msgLogger.log(msg) ; | ||
| 26 | + } | ||
| 27 | +} |
-
请 注册 或 登录 后发表评论