mirror of https://gitee.com/stylefeng/roses
【message】 websocket配置
parent
58d6f15cc4
commit
ff8995b373
|
@ -50,7 +50,7 @@ public class GunsLogAutoConfiguration {
|
|||
}
|
||||
|
||||
/**
|
||||
* 系统日志的的配置
|
||||
* 系统日志的配置
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2020/12/20 14:17
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package cn.stylefeng.roses.kernel.message.api.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 日志配置信息
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/25 9:25
|
||||
*/
|
||||
@Data
|
||||
public class MessageWebSocketProperties {
|
||||
|
||||
/**
|
||||
* websocket开关
|
||||
*/
|
||||
private Boolean open = true ;
|
||||
|
||||
/**
|
||||
* websocket地址
|
||||
*/
|
||||
private String wsUrl = "";
|
||||
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package cn.stylefeng.roses.kernel.message.starter;
|
||||
|
||||
import cn.stylefeng.roses.kernel.message.api.pojo.MessageWebSocketProperties;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
|
@ -14,8 +17,24 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
|||
@Configuration
|
||||
public class GunsMessageAutoConfiguration {
|
||||
|
||||
public static final String WEB_SOCKET_PREFIX = "web-socket";
|
||||
|
||||
|
||||
/**
|
||||
* 开启WebSocket功能
|
||||
* websocket的配置
|
||||
*
|
||||
* @author liuhanqing
|
||||
* @date 2021/1/25 9:29
|
||||
*/
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = WEB_SOCKET_PREFIX)
|
||||
public MessageWebSocketProperties sysLogProperties() {
|
||||
return new MessageWebSocketProperties();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 开启WebSocket功能
|
||||
*
|
||||
* @return serverEndpointExporter
|
||||
* @author liuhanqing
|
||||
|
@ -23,6 +42,7 @@ public class GunsMessageAutoConfiguration {
|
|||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ServerEndpointExporter.class)
|
||||
@ConditionalOnProperty(prefix = WEB_SOCKET_PREFIX, name = "open", havingValue = "true")
|
||||
public ServerEndpointExporter serverEndpointExporter() {
|
||||
return new ServerEndpointExporter();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue