Example usage for org.springframework.web.socket PingMessage PingMessage

List of usage examples for org.springframework.web.socket PingMessage PingMessage

Introduction

In this page you can find the example usage for org.springframework.web.socket PingMessage PingMessage.

Prototype

public PingMessage() 

Source Link

Document

Create a new ping message with an empty payload.

Usage

From source file:com.devicehive.websockets.util.SessionMonitor.java

@Scheduled(cron = "0/30 * * * * *")
public synchronized void ping() {
    try {/* ww w .  java2 s  .c  om*/
        for (WebSocketSession session : sessionMap.values()) {
            if (session.isOpen()) {
                logger.debug("Pinging session {}", session.getId());
                session.sendMessage(new PingMessage());
            } else {
                logger.debug("Session {} is closed.", session.getId());
                sessionMap.remove(session.getId());
            }
        }
    } catch (IOException e) {
        logger.error("Exception while ping session");
    }
}