【message】 websocket配置

pull/3/head
liuhanqing 2021-01-25 15:08:35 +08:00
parent 58d6f15cc4
commit ff8995b373
3 changed files with 46 additions and 2 deletions

View File

@ -50,7 +50,7 @@ public class GunsLogAutoConfiguration {
}
/**
*
*
*
* @author liuhanqing
* @date 2020/12/20 14:17

View File

@ -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 = "";
}

View File

@ -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();
}