1
dd
2025-10-23 5483fa32808d5fe1cbdc10f3df40316708d73c04
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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);
        }
    }
 
}