Example usage for org.springframework.web.socket WebSocketSession getClass

List of usage examples for org.springframework.web.socket WebSocketSession getClass

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:ymanv.forex.websocket.RatesWebSocketHandler.java

@Override
public void afterConnectionEstablished(WebSocketSession session) {
    LOG.debug("Opened new {} in instance {}", session.getClass().getSimpleName(), session.getRemoteAddress());
    sessions.add(session);// www .ja v  a  2  s.co m
}

From source file:ymanv.forex.websocket.RatesWebSocketHandler.java

@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) {
    LOG.debug("Closed {} in instance {}", session.getClass().getSimpleName(), session.getRemoteAddress());
    sessions.remove(session);//from  w  ww. ja  v a2s  .co  m
}

From source file:org.springframework.web.socket.sockjs.client.AbstractSockJsIntegrationTests.java

@Test
public void fallbackAfterTransportFailure() throws Exception {
    this.testFilter.sendErrorMap.put("/websocket", 200);
    this.testFilter.sendErrorMap.put("/xhr_streaming", 500);
    TestClientHandler handler = new TestClientHandler();
    initSockJsClient(createWebSocketTransport(), createXhrTransport());
    WebSocketSession session = this.sockJsClient.doHandshake(handler, this.baseUrl + "/echo").get();
    assertEquals("Fallback didn't occur", XhrClientSockJsSession.class, session.getClass());
    TextMessage message = new TextMessage("message1");
    session.sendMessage(message);//from  w  w w.  j a  va2s . c om
    handler.awaitMessage(message, 5000);
}

From source file:org.springframework.web.socket.sockjs.client.AbstractSockJsIntegrationTests.java

@Test(timeout = 5000)
public void fallbackAfterConnectTimeout() throws Exception {
    TestClientHandler clientHandler = new TestClientHandler();
    this.testFilter.sleepDelayMap.put("/xhr_streaming", 10000L);
    this.testFilter.sendErrorMap.put("/xhr_streaming", 503);
    initSockJsClient(createXhrTransport());
    this.sockJsClient.setConnectTimeoutScheduler(this.wac.getBean(ThreadPoolTaskScheduler.class));
    WebSocketSession clientSession = sockJsClient.doHandshake(clientHandler, this.baseUrl + "/echo").get();
    assertEquals("Fallback didn't occur", XhrClientSockJsSession.class, clientSession.getClass());
    TextMessage message = new TextMessage("message1");
    clientSession.sendMessage(message);/*from  ww  w  .ja va  2s  . c o  m*/
    clientHandler.awaitMessage(message, 5000);
    clientSession.close();
}