diff options
Diffstat (limited to 'juick-server-web/src/main/java/com/juick/server')
-rw-r--r-- | juick-server-web/src/main/java/com/juick/server/configuration/JuickServerComponentConfiguration.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/juick-server-web/src/main/java/com/juick/server/configuration/JuickServerComponentConfiguration.java b/juick-server-web/src/main/java/com/juick/server/configuration/JuickServerComponentConfiguration.java index 7ddda36e..5b0cf178 100644 --- a/juick-server-web/src/main/java/com/juick/server/configuration/JuickServerComponentConfiguration.java +++ b/juick-server-web/src/main/java/com/juick/server/configuration/JuickServerComponentConfiguration.java @@ -1,25 +1,34 @@ package com.juick.server.configuration; import com.juick.server.component.JuickServerComponent; +import com.juick.service.UserService; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.socket.client.WebSocketConnectionManager; import org.springframework.web.socket.client.standard.StandardWebSocketClient; +import org.springframework.web.util.UriComponentsBuilder; import javax.inject.Inject; @Configuration @EnableScheduling public class JuickServerComponentConfiguration { - @Value("${websocket_url:ws://localhost:8080/ws/}") - private String WS_URI; + @Value("${websocket_url:ws://localhost:8080/}") + private String baseUri; + @Value("${service_user:juick}") + private String serviceUser; + @Inject + private UserService userService; @Inject private JuickServerComponent juickServerComponent; @Bean public WebSocketConnectionManager connectionManager() { - WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), juickServerComponent, WS_URI); + String hash = userService.getHashByUID(userService.getUIDbyName(serviceUser)); + String websocketURI = UriComponentsBuilder.fromUriString(baseUri) + .queryParam("hash", hash).build().toUriString(); + WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), juickServerComponent, websocketURI); manager.setAutoStartup(true); return manager; } |