public void sendKeepAlive ( final Application _application ) { final long reference = new Date ( ) . getTime ( ) ; final ConcurrentMap < String , IKey > sessionId2key = _application . getMetaData ( ConnectionRegistry . SESSION2KEY ) ; final ConcurrentMap < String , Long > keepalive = _application . getMetaData ( ConnectionRegistry . KEEPALIVE ) ; if ( keepalive != null ) { for ( final Entry < String , Long > entry : keepalive . entrySet ( ) ) { if ( reference - entry . getValue ( ) > Configuration . getAttributeAsInteger ( ConfigAttribute . WEBSOCKET_KATH ) * 1000 ) { final IKey key = sessionId2key . get ( entry . getKey ( ) ) ; if ( key != null ) { final IWebSocketConnectionRegistry registry = WebSocketSettings . Holder . get ( _application ) . getConnectionRegistry ( ) ; final IWebSocketConnection conn = registry . getConnection ( _application , entry . getKey ( ) , key ) ; if ( conn != null ) { try { conn . sendMessage ( KeepAliveBehavior . MSG ) ; ConnectionRegistry . LOG . debug ( "Send KeepAlive for Session: {}" , entry . getKey ( ) ) ; } catch ( final IOException e ) { ConnectionRegistry . LOG . error ( "Catched error" , e ) ; } } } } } } }
Send the KeepAlive .