1、暂存

This commit is contained in:
2025-10-14 19:58:59 +08:00
parent 556a32cb7c
commit 643eab3496
60 changed files with 5244 additions and 657 deletions

View File

@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"strconv"
"sync"
"time"
"go-admin/models"
@ -19,6 +20,7 @@ type BinanceWs struct {
proxyUrl string
WorkType string
wsConns []*WsConn
mu sync.Mutex // 新增互斥锁
tickerCallback func(models.Ticker24, string, string)
forceCallback func(models.ForceOrder, string, string)
depthCallback func(models.DepthBin, string, string)
@ -70,11 +72,15 @@ func (bnWs *BinanceWs) subscribe(endpoint string, handle func(msg []byte) error)
if wsConn == nil {
return
}
bnWs.mu.Lock()
bnWs.wsConns = append(bnWs.wsConns, wsConn)
bnWs.mu.Unlock()
go bnWs.exitHandler(wsConn)
}
func (bnWs *BinanceWs) Close() {
bnWs.mu.Lock()
defer bnWs.mu.Unlock()
for _, con := range bnWs.wsConns {
con.CloseWs()
}