binance: pull out getEndpointUrl

This commit is contained in:
c9s 2021-12-30 16:22:29 +08:00
parent d72d57526c
commit bae7df806f

View File

@ -302,7 +302,7 @@ func (s *Stream) handleOutboundAccountPositionEvent(e *OutboundAccountPositionEv
s.EmitBalanceSnapshot(snapshot) s.EmitBalanceSnapshot(snapshot)
} }
func (s *Stream) dial(listenKey string) (*websocket.Conn, error) { func (s *Stream) getEndpointUrl(listenKey string) string {
var url string var url string
if s.PublicOnly { if s.PublicOnly {
if s.IsFutures { if s.IsFutures {
@ -318,6 +318,11 @@ func (s *Stream) dial(listenKey string) (*websocket.Conn, error) {
} }
} }
return url
}
func (s *Stream) dial(listenKey string) (*websocket.Conn, error) {
url := s.getEndpointUrl(listenKey)
conn, _, err := defaultDialer.Dial(url, nil) conn, _, err := defaultDialer.Dial(url, nil)
if err != nil { if err != nil {
return nil, err return nil, err