BAEL-252 A Java Client to consume a WebSockets API (#2048)
* BAEL-900 Guide to dynamic tests in Junit 5 * BAEL-900 Guide to Dynamic Tests in Junit 5 * Revert "BAEL-900 Guide to Dynamic Tests in Junit 5" This reverts commit d0d45c9067223347da20d0f2c80de391fcade38e. * BAEL-900 Guide to Dynamic Tests in Junit 5 * BAEL-900 Guide to dynamic tests in Junit 5 * removed unnecessary annotation * BAEL-900 unused imports removed * BAEL-900 simplified input generator code * BAEL-252 A Java Client to consume a WebSockets API
This commit is contained in:
parent
ed082d3660
commit
4b1d0217e9
@ -1,20 +1,15 @@
|
||||
package org.baeldung.websocket.client;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
|
||||
import org.springframework.messaging.simp.stomp.StompSessionHandler;
|
||||
import org.springframework.web.socket.client.WebSocketClient;
|
||||
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
|
||||
import org.springframework.web.socket.messaging.WebSocketStompClient;
|
||||
import org.springframework.web.socket.sockjs.client.SockJsClient;
|
||||
import org.springframework.web.socket.sockjs.client.Transport;
|
||||
import org.springframework.web.socket.sockjs.client.WebSocketTransport;
|
||||
|
||||
/**
|
||||
* Stand alone WebSocketStompClient.
|
||||
* @author Kalyan
|
||||
*
|
||||
*/
|
||||
public class StompClient {
|
||||
@ -22,13 +17,11 @@ public class StompClient {
|
||||
private static String URL = "ws://localhost:8080/spring-mvc-java/chat";
|
||||
|
||||
public static void main(String[] args) {
|
||||
Transport webSocketTransport = new WebSocketTransport(new StandardWebSocketClient());
|
||||
List<Transport> transports = Collections.singletonList(webSocketTransport);
|
||||
SockJsClient sockJsClient = new SockJsClient(transports);
|
||||
|
||||
WebSocketStompClient stompClient = new WebSocketStompClient(sockJsClient);
|
||||
WebSocketClient client = new StandardWebSocketClient();
|
||||
WebSocketStompClient stompClient = new WebSocketStompClient(client);
|
||||
|
||||
stompClient.setMessageConverter(new MappingJackson2MessageConverter());
|
||||
|
||||
|
||||
StompSessionHandler sessionHandler = new MyStompSessionHandler();
|
||||
stompClient.connect(URL, sessionHandler);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user