Search in sources :

Example 11 with StandardWebSocketClient

use of org.springframework.web.socket.client.standard.StandardWebSocketClient in project CVE-2018-1270 by CaledoniaProject.

the class ServiceClient method main.

public static void main(String... argv) {
    WebSocketClient webSocketClient = new StandardWebSocketClient();
    WebSocketStompClient stompClient = new WebSocketStompClient(webSocketClient);
    stompClient.setMessageConverter(new MappingJackson2MessageConverter());
    stompClient.setTaskScheduler(new ConcurrentTaskScheduler());
    String url = "ws://127.0.0.1:8080/hello";
    StompSessionHandler sessionHandler = new MySessionHandler();
    stompClient.connect(url, sessionHandler);
    // Don't close immediately.
    new Scanner(System.in).nextLine();
}
Also used : ConcurrentTaskScheduler(org.springframework.scheduling.concurrent.ConcurrentTaskScheduler) Scanner(java.util.Scanner) MappingJackson2MessageConverter(org.springframework.messaging.converter.MappingJackson2MessageConverter) StompSessionHandler(org.springframework.messaging.simp.stomp.StompSessionHandler) WebSocketStompClient(org.springframework.web.socket.messaging.WebSocketStompClient) StandardWebSocketClient(org.springframework.web.socket.client.standard.StandardWebSocketClient) WebSocketClient(org.springframework.web.socket.client.WebSocketClient) StandardWebSocketClient(org.springframework.web.socket.client.standard.StandardWebSocketClient)

Example 12 with StandardWebSocketClient

use of org.springframework.web.socket.client.standard.StandardWebSocketClient 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

StandardWebSocketClient (org.springframework.web.socket.client.standard.StandardWebSocketClient)12 WebSocketClient (org.springframework.web.socket.client.WebSocketClient)8 WebSocketStompClient (org.springframework.web.socket.messaging.WebSocketStompClient)4 SockJsClient (org.springframework.web.socket.sockjs.client.SockJsClient)4 Transport (org.springframework.web.socket.sockjs.client.Transport)4 WebSocketTransport (org.springframework.web.socket.sockjs.client.WebSocketTransport)4 WsWebSocketContainer (org.apache.tomcat.websocket.WsWebSocketContainer)3 MappingJackson2MessageConverter (org.springframework.messaging.converter.MappingJackson2MessageConverter)3 StringMessageConverter (org.springframework.messaging.converter.StringMessageConverter)3 StompSessionHandler (org.springframework.messaging.simp.stomp.StompSessionHandler)3 RestTemplateXhrTransport (org.springframework.web.socket.sockjs.client.RestTemplateXhrTransport)3 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 Scanner (java.util.Scanner)2 Before (org.junit.Before)2 Test (org.junit.Test)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 RestTemplate (org.springframework.web.client.RestTemplate)2 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)2 TomcatWebSocketTestServer (org.springframework.web.socket.TomcatWebSocketTestServer)2