1
1
package binance
2
2
3
3
import (
4
+ stdjson "encoding/json"
4
5
"fmt"
5
6
"strings"
6
7
"time"
7
-
8
- stdjson "encoding/json"
9
- )
10
-
11
- // Endpoints
12
- const (
13
- baseWsMainURL = "wss://stream.binance.com:9443/ws"
14
- baseWsTestnetURL = "wss://testnet.binance.vision/ws"
15
- baseCombinedMainURL = "wss://stream.binance.com:9443/stream?streams="
16
- baseCombinedTestnetURL = "wss://testnet.binance.vision/stream?streams="
17
8
)
18
9
19
10
var (
11
+ // Endpoints
12
+ BaseWsMainURL = "wss://stream.binance.com:9443/ws"
13
+ BaseWsTestnetURL = "wss://testnet.binance.vision/ws"
14
+ BaseCombinedMainURL = "wss://stream.binance.com:9443/stream?streams="
15
+ BaseCombinedTestnetURL = "wss://testnet.binance.vision/stream?streams="
16
+
20
17
// WebsocketTimeout is an interval for sending ping/pong messages if WebsocketKeepalive is enabled
21
18
WebsocketTimeout = time .Second * 60
22
19
// WebsocketKeepalive enables sending ping/pong messages to check the connection stability
@@ -26,17 +23,17 @@ var (
26
23
// getWsEndpoint return the base endpoint of the WS according the UseTestnet flag
27
24
func getWsEndpoint () string {
28
25
if UseTestnet {
29
- return baseWsTestnetURL
26
+ return BaseWsTestnetURL
30
27
}
31
- return baseWsMainURL
28
+ return BaseWsMainURL
32
29
}
33
30
34
31
// getCombinedEndpoint return the base endpoint of the combined stream according the UseTestnet flag
35
32
func getCombinedEndpoint () string {
36
33
if UseTestnet {
37
- return baseCombinedTestnetURL
34
+ return BaseCombinedTestnetURL
38
35
}
39
- return baseCombinedMainURL
36
+ return BaseCombinedMainURL
40
37
}
41
38
42
39
// WsPartialDepthEvent define websocket partial depth book event
@@ -797,7 +794,7 @@ func WsBookTickerServe(symbol string, handler WsBookTickerHandler, errHandler Er
797
794
798
795
// WsCombinedBookTickerServe is similar to WsBookTickerServe, but it is for multiple symbols
799
796
func WsCombinedBookTickerServe (symbols []string , handler WsBookTickerHandler , errHandler ErrHandler ) (doneC , stopC chan struct {}, err error ) {
800
- endpoint := baseCombinedMainURL
797
+ endpoint := getCombinedEndpoint ()
801
798
for _ , s := range symbols {
802
799
endpoint += fmt .Sprintf ("%s@bookTicker" , strings .ToLower (s )) + "/"
803
800
}
0 commit comments