Search in sources :

Example 6 with WebSocketStompClient

use of org.springframework.web.socket.messaging.WebSocketStompClient in project yaps-client by serdaroquai.

the class WebsocketConfig method webSocketClient.

@Bean
public WebSocketStompClient webSocketClient(TaskScheduler taskScheduler) {
    List<Transport> transports = new ArrayList<Transport>();
    transports.add(new WebSocketTransport(new StandardWebSocketClient()));
    WebSocketClient transport = new SockJsClient(transports);
    WebSocketStompClient stompClient = new WebSocketStompClient(transport);
    stompClient.setMessageConverter(new MappingJackson2MessageConverter());
    // for heartbeats
    stompClient.setTaskScheduler(taskScheduler);
    return stompClient;
}
Also used : MappingJackson2MessageConverter(org.springframework.messaging.converter.MappingJackson2MessageConverter) SockJsClient(org.springframework.web.socket.sockjs.client.SockJsClient) ArrayList(java.util.ArrayList) WebSocketStompClient(org.springframework.web.socket.messaging.WebSocketStompClient) StandardWebSocketClient(org.springframework.web.socket.client.standard.StandardWebSocketClient) Transport(org.springframework.web.socket.sockjs.client.Transport) WebSocketTransport(org.springframework.web.socket.sockjs.client.WebSocketTransport) StandardWebSocketClient(org.springframework.web.socket.client.standard.StandardWebSocketClient) WebSocketClient(org.springframework.web.socket.client.WebSocketClient) WebSocketTransport(org.springframework.web.socket.sockjs.client.WebSocketTransport) Bean(org.springframework.context.annotation.Bean)

Aggregations

WebSocketStompClient (org.springframework.web.socket.messaging.WebSocketStompClient)6 StompSessionHandler (org.springframework.messaging.simp.stomp.StompSessionHandler)5 WebSocketClient (org.springframework.web.socket.client.WebSocketClient)4 StandardWebSocketClient (org.springframework.web.socket.client.standard.StandardWebSocketClient)4 MappingJackson2MessageConverter (org.springframework.messaging.converter.MappingJackson2MessageConverter)3 StompSession (org.springframework.messaging.simp.stomp.StompSession)3 Type (java.lang.reflect.Type)2 Scanner (java.util.Scanner)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 ServerPortInfoApplicationContextInitializer (org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer)2 SimpleMessageConverter (org.springframework.messaging.converter.SimpleMessageConverter)2 StompCommand (org.springframework.messaging.simp.stomp.StompCommand)2 StompFrameHandler (org.springframework.messaging.simp.stomp.StompFrameHandler)2 StompHeaders (org.springframework.messaging.simp.stomp.StompHeaders)2 StompSessionHandlerAdapter (org.springframework.messaging.simp.stomp.StompSessionHandlerAdapter)2 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 WebSocketContainer (javax.websocket.WebSocketContainer)1