21 Ocak 2021 Perşembe

SpringWebSocket WebSocketConnectionManager Sınıfı

Giriş
Şu satırı dahil ederiz
import org.springframework.web.socket.client.WebSocketConnectionManager;
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
import org.springframework.web.socket.handler.TextWebSocketHandler;
constructor
Şöyle yaparız
public class MyTextWebSocketHandler extends TextWebSocketHandler {...}

String wsUrl = ...;
//A WebSocket connection manager that is given a URI, a WebSocketClient, and a
//WebSocketHandler, connects to a WebSocket server through start() and stop() methods. 
//If setAutoStartup(boolean) is set to true this will be done automatically when the Spring
//ApplicationContext is refreshed.
WebSocketConnectionManager connectionManager = 
  new WebSocketConnectionManager(new StandardWebSocketClient(),
                                 new MyTextWebSocketHandler(), 
                                 wsUrl);
connectionManager.start();

Hiç yorum yok:

Yorum Gönder