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;
|
package org.baeldung.websocket.client;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
|
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
|
||||||
import org.springframework.messaging.simp.stomp.StompSessionHandler;
|
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.client.standard.StandardWebSocketClient;
|
||||||
import org.springframework.web.socket.messaging.WebSocketStompClient;
|
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.
|
* Stand alone WebSocketStompClient.
|
||||||
* @author Kalyan
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class StompClient {
|
public class StompClient {
|
||||||
@ -22,11 +17,9 @@ public class StompClient {
|
|||||||
private static String URL = "ws://localhost:8080/spring-mvc-java/chat";
|
private static String URL = "ws://localhost:8080/spring-mvc-java/chat";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Transport webSocketTransport = new WebSocketTransport(new StandardWebSocketClient());
|
WebSocketClient client = new StandardWebSocketClient();
|
||||||
List<Transport> transports = Collections.singletonList(webSocketTransport);
|
WebSocketStompClient stompClient = new WebSocketStompClient(client);
|
||||||
SockJsClient sockJsClient = new SockJsClient(transports);
|
|
||||||
|
|
||||||
WebSocketStompClient stompClient = new WebSocketStompClient(sockJsClient);
|
|
||||||
stompClient.setMessageConverter(new MappingJackson2MessageConverter());
|
stompClient.setMessageConverter(new MappingJackson2MessageConverter());
|
||||||
|
|
||||||
StompSessionHandler sessionHandler = new MyStompSessionHandler();
|
StompSessionHandler sessionHandler = new MyStompSessionHandler();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user