【7.3.0】更新配置监听设置

pull/40/MERGE
fengshuonan 2022-10-22 22:01:51 +08:00
parent 8076ceae65
commit 227a4401e3
3 changed files with 25 additions and 2 deletions

View File

@ -33,19 +33,23 @@ import cn.stylefeng.roses.kernel.auth.api.cookie.SessionCookieCreator;
import cn.stylefeng.roses.kernel.auth.api.expander.AuthConfigExpander;
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
import cn.stylefeng.roses.kernel.message.api.expander.WebSocketConfigExpander;
import cn.stylefeng.roses.kernel.rule.callback.ConfigUpdateCallback;
import cn.stylefeng.roses.kernel.rule.util.HttpServletUtil;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import static cn.stylefeng.roses.kernel.message.api.constants.MessageConstants.WEB_SOCKET_WS_URL_CONFIG_CODE;
/**
* redis
*
* @author fengshuonan
* @date 2019-09-28-14:43
*/
public class DefaultSessionManager implements SessionManagerApi {
public class DefaultSessionManager implements SessionManagerApi, ConfigUpdateCallback {
/**
*
@ -215,4 +219,14 @@ public class DefaultSessionManager implements SessionManagerApi {
return loginUsers;
}
@Override
public void configUpdate(String code, String value) {
// 如果系统配置修改了websocket url则刷新所有在线用户的配置
if (WEB_SOCKET_WS_URL_CONFIG_CODE.equals(code)) {
List<LoginUser> loginUsers = this.onlineUserList();
for (LoginUser loginUser : loginUsers) {
loginUser.setWsUrl(WebSocketConfigExpander.getWebSocketWsUrl());
}
}
}
}

View File

@ -52,4 +52,9 @@ public interface MessageConstants {
*/
String DEFAULT_WS_URL = "ws://localhost:8080/webSocket/{token}";
/**
* websocket url
*/
String WEB_SOCKET_WS_URL_CONFIG_CODE = "WEB_SOCKET_WS_URL";
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
import cn.stylefeng.roses.kernel.config.api.constants.ConfigConstants;
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
@ -254,7 +255,10 @@ public class SysThemeServiceImpl extends ServiceImpl<SysThemeMapper, SysTheme> i
@Override
public void configUpdate(String code, String value) {
clearThemeCache();
// 如果服务默认部署的环境地址被修改
if (ConfigConstants.SYS_SERVER_DEPLOY_HOST.equals(code)) {
clearThemeCache();
}
}
/**