diff options
author | 2017-11-02 16:02:17 +0300 | |
---|---|---|
committer | 2017-11-02 16:12:40 +0300 | |
commit | ee20020d9c576a48173c13b68b03d349c0ec3e47 (patch) | |
tree | 7c59dcac74cde4e5b819a245dc0fbbb315020f10 /juick-server-web/src/main/java/com/juick/server/configuration/JuickServerComponentConfiguration.java | |
parent | 61c6a3fe338a5cbbef55081f8ac26011c053125d (diff) |
server-web: base websocket component with autoreconnect
Diffstat (limited to 'juick-server-web/src/main/java/com/juick/server/configuration/JuickServerComponentConfiguration.java')
-rw-r--r-- | juick-server-web/src/main/java/com/juick/server/configuration/JuickServerComponentConfiguration.java | 30 |
1 files changed, 30 insertions, 0 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 new file mode 100644 index 00000000..7ddda36e --- /dev/null +++ b/juick-server-web/src/main/java/com/juick/server/configuration/JuickServerComponentConfiguration.java @@ -0,0 +1,30 @@ +package com.juick.server.configuration; + +import com.juick.server.component.JuickServerComponent; +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 javax.inject.Inject; + +@Configuration +@EnableScheduling +public class JuickServerComponentConfiguration { + @Value("${websocket_url:ws://localhost:8080/ws/}") + private String WS_URI; + @Inject + private JuickServerComponent juickServerComponent; + @Bean + public WebSocketConnectionManager connectionManager() { + WebSocketConnectionManager manager = new WebSocketConnectionManager(client(), juickServerComponent, WS_URI); + manager.setAutoStartup(true); + return manager; + } + @Bean + public StandardWebSocketClient client() { + return new StandardWebSocketClient(); + } +} |