Add heartbeats and bump versions
This commit is contained in:
parent
59ae9b279d
commit
d66bc9c900
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.7.RELEASE</version>
|
||||
<version>1.5.10.RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.charego</groupId>
|
||||
|
@ -3,6 +3,8 @@ package lingo.server;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.messaging.simp.config.ChannelRegistration;
|
||||
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
|
||||
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
|
||||
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
|
||||
@ -25,7 +27,9 @@ public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
|
||||
|
||||
@Override
|
||||
public void configureMessageBroker(MessageBrokerRegistry registry) {
|
||||
registry.enableSimpleBroker("/topic");
|
||||
registry.enableSimpleBroker("/topic")
|
||||
.setTaskScheduler(heartbeatScheduler())
|
||||
.setHeartbeatValue(heartbeatValue());
|
||||
registry.setApplicationDestinationPrefixes("/app", "/user");
|
||||
registry.setUserDestinationPrefix("/user");
|
||||
}
|
||||
@ -36,4 +40,17 @@ public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
|
||||
registry.addEndpoint("/stomp");
|
||||
}
|
||||
|
||||
private TaskScheduler heartbeatScheduler() {
|
||||
// Single thread unless/until more threads are needed
|
||||
final ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
|
||||
taskScheduler.setPoolSize(1);
|
||||
taskScheduler.setThreadNamePrefix("Keep-Alive-");
|
||||
taskScheduler.initialize();
|
||||
return taskScheduler;
|
||||
}
|
||||
|
||||
private long[] heartbeatValue() {
|
||||
return new long[] { 25000, 25000 };
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -280,6 +280,8 @@ function main() {
|
||||
}
|
||||
|
||||
client = Stomp.client(`${webSocketProtocol}://${location.host}/stomp`);
|
||||
client.heartbeat.outgoing = 25000; // send PING every 25 seconds
|
||||
client.heartbeat.incoming = 0; // do NOT want PONGs from server
|
||||
client.connect({}, afterConnected, function(errorMessage) {
|
||||
addChatAnnouncement(errorMessage);
|
||||
addChatAnnouncement('Please reload the page!');
|
||||
|
@ -5,7 +5,7 @@
|
||||
<title>Lingo</title>
|
||||
<link rel="stylesheet" href="layout.css">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/vue/2.5.2/vue.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="vue-app" v-cloak>
|
||||
|
Loading…
x
Reference in New Issue
Block a user