|
|
@@ -31,13 +31,11 @@ type Client struct {
|
|
|
quoteWriteChan chan []byte // 推送队列 Access -> Client
|
|
|
quoteChan chan interface{} // 接收实时行情订阅channel QuoteServer -> Access
|
|
|
quoteSubs []request.QuoteGoods // 当前已订阅行情的商品
|
|
|
- qmtx sync.RWMutex
|
|
|
// wsQuoteCloseChan chan struct{} // 终端WebSocket连接关闭信号
|
|
|
|
|
|
wsTradeConn *websocket.Conn // 终端交易WebSocket连接
|
|
|
tradeWriteChan chan []byte // 推送队列 Access -> Client
|
|
|
tradeChan chan interface{} // 接收交易通知channel RabbitMQ -> Access
|
|
|
- tmtx sync.RWMutex
|
|
|
// wsTradeCloseChan chan struct{} // 终端WebSocket连接关闭信号
|
|
|
}
|
|
|
|
|
|
@@ -54,8 +52,8 @@ func (r *Client) GetSerialNumber() uint32 {
|
|
|
|
|
|
// SetQuoteSubs 设置商品行情订阅信息
|
|
|
func (r *Client) SetQuoteSubs(req request.QuoteSubscribeReq) {
|
|
|
- r.qmtx.Lock()
|
|
|
- defer r.qmtx.Unlock()
|
|
|
+ // r.qmtx.Lock()
|
|
|
+ // defer r.qmtx.Unlock()
|
|
|
|
|
|
r.quoteSubs = req.QuoteGoodses
|
|
|
|
|
|
@@ -82,8 +80,8 @@ func (r *Client) SetQuoteSubs(req request.QuoteSubscribeReq) {
|
|
|
// SetQuoteSubs 设置交易通知订阅信息
|
|
|
func (r *Client) SetTradeNft() {
|
|
|
global.M2A_LOG.Info("SetTradeNft 11111111111111111111111111111")
|
|
|
- r.tmtx.Lock()
|
|
|
- defer r.tmtx.Unlock()
|
|
|
+ // r.tmtx.Lock()
|
|
|
+ // defer r.tmtx.Unlock()
|
|
|
|
|
|
// 从订阅中心订阅交易通知
|
|
|
if r.tradeChan != nil {
|
|
|
@@ -114,8 +112,8 @@ func (r *Client) SetTradeNft() {
|
|
|
|
|
|
// GetQuoteSubs 获取已订阅行情商品信息列表
|
|
|
func (r *Client) GetQuoteSubs() (quoteSubs []request.QuoteGoods) {
|
|
|
- r.qmtx.Lock()
|
|
|
- defer r.qmtx.Unlock()
|
|
|
+ r.mtx.Lock()
|
|
|
+ defer r.mtx.Unlock()
|
|
|
|
|
|
return r.quoteSubs
|
|
|
}
|
|
|
@@ -200,8 +198,10 @@ func (r *Client) GetAllAsyncTask() *map[string]*AsyncTask {
|
|
|
// **************** Quote WebSocket ****************
|
|
|
|
|
|
func (r *Client) SetQuoteWebSocket(ws *websocket.Conn) (err error) {
|
|
|
- r.qmtx.Lock()
|
|
|
- defer r.qmtx.Unlock()
|
|
|
+ global.M2A_LOG.Info("行情长连 SetQuoteWebSocket 22222222222222")
|
|
|
+
|
|
|
+ r.mtx.Lock()
|
|
|
+ defer r.mtx.Unlock()
|
|
|
|
|
|
// if r.wsQuoteConn != nil {
|
|
|
// r.wsQuoteConn.Close()
|
|
|
@@ -219,6 +219,8 @@ func (r *Client) SetQuoteWebSocket(ws *websocket.Conn) (err error) {
|
|
|
// return nil
|
|
|
// })
|
|
|
|
|
|
+ global.M2A_LOG.Info("行情长连客户端接入", zap.Any("LoginID", r.LoginID), zap.Any("SessionID", r.SessionID))
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -311,8 +313,10 @@ func (r *Client) clientToQuoteAgentMsg(msg []byte) error {
|
|
|
// **************** Trade WebSocket ****************
|
|
|
|
|
|
func (r *Client) SetTradeWebSocket(ws *websocket.Conn) (err error) {
|
|
|
- r.tmtx.Lock()
|
|
|
- defer r.tmtx.Unlock()
|
|
|
+ global.M2A_LOG.Info("交易长连 SetTradeWebSocket 33333333333333333333")
|
|
|
+
|
|
|
+ r.mtx.Lock()
|
|
|
+ defer r.mtx.Unlock()
|
|
|
|
|
|
// if r.wsTradeConn != nil {
|
|
|
// r.wsTradeConn.Close()
|