Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ISAAC-XXYYZZ committed Sep 4, 2024
2 parents 02de470 + a4c561e commit f19b383
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ func NewUnsubscribeMessage(topic string, privateChannel bool) *WebSocketUnsubscr
// A WebSocketDownstreamMessage represents a message from the WebSocket server to client.
type WebSocketDownstreamMessage struct {
*WebSocketMessage
Sn string `json:"sn"`
Topic string `json:"topic"`
Subject string `json:"subject"`
RawData jsoniter.RawMessage `json:"data"`
Sn int64 `json:"sn"`
Topic string `json:"topic"`
Subject string `json:"subject"`
RawData json.RawMessage `json:"data"`
}

// ReadData read the data in channel.
Expand Down Expand Up @@ -192,7 +192,7 @@ func (wc *WebSocketClient) Connect() (<-chan *WebSocketDownstreamMessage, <-chan
websocket.DefaultDialer.TLSClientConfig = &tls.Config{InsecureSkipVerify: wc.skipVerifyTls}

// Connect ws server
websocket.DefaultDialer.ReadBufferSize = 2048000 //2000 kb
websocket.DefaultDialer.ReadBufferSize = 2048000 // 2000 kb
wc.conn, _, err = websocket.DefaultDialer.Dial(u, nil)
if err != nil {
return wc.messages, wc.errors, err
Expand Down Expand Up @@ -313,10 +313,10 @@ func (wc *WebSocketClient) Subscribe(channels ...*WebSocketSubscribeMessage) err
if err := wc.conn.WriteMessage(websocket.TextMessage, []byte(m)); err != nil {
return err
}
//log.Printf("Subscribing: %s, %s", c.Id, c.Topic)
// log.Printf("Subscribing: %s, %s", c.Id, c.Topic)
select {
case id := <-wc.acks:
//log.Printf("ack: %s=>%s", id, c.Id)
// log.Printf("ack: %s=>%s", id, c.Id)
if id != c.Id {
return errors.Errorf("Invalid ack id %s, expect %s", id, c.Id)
}
Expand All @@ -339,10 +339,10 @@ func (wc *WebSocketClient) Unsubscribe(channels ...*WebSocketUnsubscribeMessage)
if err := wc.conn.WriteMessage(websocket.TextMessage, []byte(m)); err != nil {
return err
}
//log.Printf("Unsubscribing: %s, %s", c.Id, c.Topic)
// log.Printf("Unsubscribing: %s, %s", c.Id, c.Topic)
select {
case id := <-wc.acks:
//log.Printf("ack: %s=>%s", id, c.Id)
// log.Printf("ack: %s=>%s", id, c.Id)
if id != c.Id {
return errors.Errorf("Invalid ack id %s, expect %s", id, c.Id)
}
Expand Down

0 comments on commit f19b383

Please sign in to comment.