aboutsummaryrefslogtreecommitdiff
path: root/juick-notifications/src/main/java/com/juick/components/service/JuickServerReconnectManager.java
blob: f83a3aa045fa8f2eb0eade38161efe9e606935cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.juick.components.service;

import com.juick.server.component.DisconnectedEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.client.WebSocketConnectionManager;

import javax.inject.Inject;

@Component
public class JuickServerReconnectManager implements ApplicationListener<DisconnectedEvent> {
    private static Logger logger = LoggerFactory.getLogger(JuickServerReconnectManager.class);
    @Inject
    private WebSocketConnectionManager webSocketConnectionManager;
    @Override
    public void onApplicationEvent(DisconnectedEvent event) {
        logger.info("retrying...");
        webSocketConnectionManager.stop();
        webSocketConnectionManager.start();
    }
}