|
@@ -3,6 +3,7 @@ package com.fjhx.socket.core;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.fjhx.socket.core.event.WebSocketOnMessageEvent;
|
|
|
import com.fjhx.socket.core.event.WebSocketOnOpenEvent;
|
|
@@ -10,6 +11,7 @@ import com.fjhx.socket.core.event.WebSocketSendFailEvent;
|
|
|
import com.fjhx.socket.core.event.WebSocketSendSuccessEvent;
|
|
|
import com.fjhx.socket.entity.push.po.PushInfo;
|
|
|
import com.fjhx.socket.service.push.PushInfoService;
|
|
|
+import com.ruoyi.common.constant.BaseSourceConstant;
|
|
|
import com.ruoyi.common.constant.StatusConstant;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
@@ -71,6 +73,8 @@ public class WebSocketServer {
|
|
|
@OnOpen
|
|
|
public void onOpen(@RequestBody Session session, @PathParam("token") String token) {
|
|
|
|
|
|
+ DynamicDataSourceContextHolder.push(BaseSourceConstant.BASE);
|
|
|
+
|
|
|
// 解析token
|
|
|
LoginUser loginUser = tokenService.getLoginUser(token);
|
|
|
|
|
@@ -101,6 +105,8 @@ public class WebSocketServer {
|
|
|
|
|
|
// 发布建立连接连接事件
|
|
|
applicationContext.publishEvent(new WebSocketOnOpenEvent(this));
|
|
|
+
|
|
|
+ DynamicDataSourceContextHolder.poll();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -142,6 +148,8 @@ public class WebSocketServer {
|
|
|
*/
|
|
|
protected void sendMessage(PushTypeEnum pushTypeEnum, PushParam pushParam) {
|
|
|
|
|
|
+ DynamicDataSourceContextHolder.push(BaseSourceConstant.BASE);
|
|
|
+
|
|
|
JSONObject msg = new JSONObject();
|
|
|
msg.put("type", pushTypeEnum.getType());
|
|
|
|
|
@@ -181,6 +189,7 @@ public class WebSocketServer {
|
|
|
applicationContext.publishEvent(new WebSocketSendFailEvent(pushTypeEnum, pushParam));
|
|
|
}
|
|
|
|
|
|
+ DynamicDataSourceContextHolder.poll();
|
|
|
}
|
|
|
|
|
|
}
|