Giriş
Bu sınıf WebSocketStompClient nesnesine parametre olarak geçilir.
constructor
Şöyle yaparız
Şöyle yaparız
WebSocketClient simpleWebSocketClient = new StandardWebSocketClient();
doHandshake metoduŞöyle yaparız
final CountDownLatch latch = new CountDownLatch(1);EchoHandler handler = new EchoHandler(latch);WebSocketClient client = new StandardWebSocketClient();WebSocketSession session = client.doHandshake(handler, ECHO_URL).get();session.sendMessage(new TextMessage("Hello World"));latch.await(5000, TimeUnit.SECONDS);session.close();public class EchoHandler extends TextWebSocketHandler {private final CountDownLatch latch;public EchoHandler(CountDownLatch latch) {this.latch = latch;}@Overridepublic void handleTextMessage(WebSocketSession session, TextMessage message) {System.out.println("------- received client message ------");System.out.println(message.getPayload());System.out.println("--------- end client message ---------");latch.countDown();}}
Hiç yorum yok:
Yorum Gönder