/** * Return a String describing internal state and counters. */ public String getStatsInfo() { return this.stats.toString(); }
/** * Return a String describing internal state and counters. */ public String getStatsInfo() { return this.stats.toString(); }
/** * Connect to the given WebSocket URL and notify the given * {@link org.springframework.messaging.simp.stomp.StompSessionHandler} * when connected on the STOMP level after the CONNECTED frame is received. * @param url the url to connect to * @param handler the session handler * @param uriVars the URI variables to expand into the URL * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(String url, StompSessionHandler handler, Object... uriVars) { return connect(url, null, handler, uriVars); }
@Override public void afterConnectionEstablished(WebSocketSession session) throws Exception { // WebSocketHandlerDecorator could close the session if (!session.isOpen()) { return; } this.stats.incrementSessionCount(session); session = decorateSession(session); this.sessions.put(session.getId(), new WebSocketSessionHolder(session)); findProtocolHandler(session).afterSessionStarted(session, this.clientInboundChannel); }
@Test public void nullSessionId() throws Exception { DefaultSimpUserRegistry registry = new DefaultSimpUserRegistry(); TestPrincipal user = new TestPrincipal("joe"); Message<byte[]> message = createMessage(SimpMessageType.CONNECT_ACK, "123"); SessionConnectedEvent event = new SessionConnectedEvent(this, message, user); registry.onApplicationEvent(event); SimpUser simpUser = registry.getUser("joe"); assertNull(simpUser.getSession(null)); }
private void clearSession(WebSocketSession session, CloseStatus closeStatus) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Clearing session " + session.getId()); } if (this.sessions.remove(session.getId()) != null) { this.stats.decrementSessionCount(session); } findProtocolHandler(session).afterSessionEnded(session, closeStatus, this.clientInboundChannel); }
@Override public int hashCode() { return getId().hashCode() * 31 + getSession().getId().hashCode(); }
@Override public String toString() { return "StompSubProtocolHandler" + getSupportedProtocols(); }
protected void setApplicationContext(ApplicationContext applicationContext) { this.stompHandler.setApplicationEventPublisher(applicationContext); }
@Override public String toString() { return "name=" + getName() + ", sessions=" + this.userSessions; } }
@Override public String toString() { return "id=" + getId() + ", subscriptions=" + this.subscriptions; } }
/** * Get stats about WebSocket sessions. */ public String getWebSocketSessionStatsInfo() { return (this.webSocketHandler != null ? this.webSocketHandler.getStatsInfo() : "null"); }
/** * Get stats about STOMP-related WebSocket message processing. */ public String getStompSubProtocolStatsInfo() { return (this.stompSubProtocolHandler != null ? this.stompSubProtocolHandler.getStatsInfo() : "null"); }
@Override public WebMvcStompEndpointRegistry setErrorHandler(StompSubProtocolErrorHandler errorHandler) { this.stompHandler.setErrorHandler(errorHandler); return this; }
@Override public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception { this.stats.incrementTransportError(); }
@Override public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception { clearSession(session, closeStatus); }
@IntegrationTestController static class IncrementController { @MessageMapping("/increment") public int handle(int i) { return i + 1; } @SubscribeMapping("/number") public int number() { return 42; } }
private Message<byte[]> createMessage(SimpMessageType type, String sessionId) { return createMessage(type, sessionId, null, null); }
public static StompTextMessageBuilder create(StompCommand command) { return new StompTextMessageBuilder(command); }
@IntegrationTestController static class ScopedBeanController { private final ScopedBean scopedBean; @Autowired public ScopedBeanController(ScopedBean scopedBean) { this.scopedBean = scopedBean; } @MessageMapping("/scopedBeanValue") public String getValue() { return this.scopedBean.getValue(); } }