Example usage for org.springframework.boot.devtools.livereload ConnectionClosedException ConnectionClosedException

List of usage examples for org.springframework.boot.devtools.livereload ConnectionClosedException ConnectionClosedException

Introduction

In this page you can find the example usage for org.springframework.boot.devtools.livereload ConnectionClosedException ConnectionClosedException.

Prototype

ConnectionClosedException() 

Source Link

Usage

From source file:org.springframework.boot.devtools.livereload.Connection.java

private void readWebSocketFrame() throws IOException {
    try {/*from  w ww.ja v a  2  s. com*/
        Frame frame = Frame.read(this.inputStream);
        if (frame.getType() == Frame.Type.PING) {
            writeWebSocketFrame(new Frame(Frame.Type.PONG));
        } else if (frame.getType() == Frame.Type.CLOSE) {
            throw new ConnectionClosedException();
        } else if (frame.getType() == Frame.Type.TEXT) {
            logger.debug("Recieved LiveReload text frame " + frame);
        } else {
            throw new IOException("Unexpected Frame Type " + frame.getType());
        }
    } catch (SocketTimeoutException ex) {
        writeWebSocketFrame(new Frame(Frame.Type.PING));
        Frame frame = Frame.read(this.inputStream);
        if (frame.getType() != Frame.Type.PONG) {
            throw new IllegalStateException("No Pong");
        }
    }
}