-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #194 from sopra-fs24-group-09/develop
Develop
- Loading branch information
Showing
4 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 29 additions & 6 deletions
35
src/main/java/ch/uzh/ifi/hase/soprafs24/config/WebSocketConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,51 @@ | ||
package ch.uzh.ifi.hase.soprafs24.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.messaging.simp.config.MessageBrokerRegistry; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; | ||
import org.springframework.web.socket.config.annotation.StompEndpointRegistry; | ||
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; | ||
import org.springframework.messaging.simp.config.ChannelRegistration; | ||
|
||
@Configuration | ||
@EnableWebSocketMessageBroker | ||
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { | ||
|
||
@Override | ||
public void registerStompEndpoints(StompEndpointRegistry registry) { | ||
public void registerStompEndpoints(@SuppressWarnings("null") StompEndpointRegistry registry) { | ||
registry.addEndpoint("/ws") | ||
.setAllowedOriginPatterns("*") | ||
.withSockJS(); | ||
// .setInterceptors(new RoomIdInterceptor()); | ||
} | ||
|
||
|
||
@Override | ||
public void configureMessageBroker(MessageBrokerRegistry registry) { | ||
public void configureMessageBroker(@SuppressWarnings("null") MessageBrokerRegistry registry) { | ||
registry.setApplicationDestinationPrefixes("/app"); | ||
registry.enableSimpleBroker("/user","/game","/plays/info","/games/info","/plays/audio", "/response","/lobby/info"); | ||
registry.enableSimpleBroker("/user", "/game", "/plays/info", "/games/info", "/plays/audio", "/response", "/lobby/info"); | ||
registry.setUserDestinationPrefix("/user"); | ||
} | ||
} | ||
|
||
@Bean(name = "webSocketTaskExecutor") | ||
public ThreadPoolTaskExecutor webSocketTaskExecutor() { | ||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | ||
executor.setCorePoolSize(10); | ||
executor.setMaxPoolSize(20); | ||
executor.setQueueCapacity(50); | ||
executor.setThreadNamePrefix("WebSocket-"); | ||
executor.initialize(); | ||
return executor; | ||
} | ||
|
||
@Override | ||
public void configureClientInboundChannel(ChannelRegistration registration) { | ||
registration.taskExecutor(webSocketTaskExecutor()); | ||
} | ||
|
||
@Override | ||
public void configureClientOutboundChannel(ChannelRegistration registration) { | ||
registration.taskExecutor(webSocketTaskExecutor()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters