RealtimeResource { @OnClose public void close(Session session, CloseReason reason) { LOG.info("Closing session {}. Reason {}", session.getId(), reason); try { session.close(); } catch (IOException e) { LOG.warn("Couldn't close {}. Reason {}", session.getId(), e.getMessage()); } sessions.remove(session); } RealtimeResource(); @OnOpen void openSocket(@PathParam(RT_COMPUTE_ENDPOINT_PARAM) ConnectionType type,
                           Session session); @OnMessage void publishEvent(ChatAlyticsEvent event); @OnClose void close(Session session, CloseReason reason); @OnError void onError(Throwable t); int numSessions(); static final String RT_COMPUTE_ENDPOINT; static final String RT_FULL_ENDPOINT; }
@Test public void testClose() throws Exception { underTest.openSocket(ConnectionType.SUBSCRIBER, session); verify(session).getId(); verify(session).setMaxIdleTimeout(0); verifyNoMoreInteractions(session); assertEquals(1, underTest.numSessions()); underTest.close(session, new CloseReason(CloseCodes.CANNOT_ACCEPT, "close")); verify(session).close(); verify(session, times(2)).getId(); verifyNoMoreInteractions(session); assertEquals(0, underTest.numSessions()); }