package com.nq.ws;
|
|
|
import com.nq.enums.EStockType;
|
import com.nq.utils.PropertiesUtil;
|
import lombok.extern.slf4j.Slf4j;
|
import org.java_websocket.client.WebSocketClient;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
|
import java.net.URI;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
@Slf4j
|
@Configuration
|
public class WebSocketClientBeanConfig {
|
|
|
@Bean
|
public void websocketRunClientMap() {
|
|
// 创建WebSocket客户端实例
|
try {
|
URI serverUri = new URI("wss://ws.durocaspitall.com/websocket-server");
|
EStockType stockType = EStockType.IN; // 根据你的枚举调整
|
|
WebsocketRunClient client = new WebsocketRunClient(serverUri, stockType);
|
client.connect();
|
|
} catch (Exception e) {
|
log.error("创建WebSocket客户端失败: {}", e.getMessage(), e);
|
}
|
}
|
|
}
|