28 lines
973 B
Java
28 lines
973 B
Java
package de.ph87.homeautomation.web;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
|
|
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
|
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
|
|
|
|
@CrossOrigin
|
|
@Configuration
|
|
@EnableWebSocketMessageBroker
|
|
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
|
|
|
|
public static final String DESTINATION_PREFIX = "/updates";
|
|
|
|
@Override
|
|
public void registerStompEndpoints(StompEndpointRegistry registry) {
|
|
registry.addEndpoint("/websocket").setAllowedOrigins("*");
|
|
}
|
|
|
|
@Override
|
|
public void configureMessageBroker(MessageBrokerRegistry config) {
|
|
config.enableSimpleBroker(DESTINATION_PREFIX);
|
|
}
|
|
|
|
}
|