From: qydysky Date: Sun, 11 Aug 2024 14:58:57 +0000 (+0800) Subject: 1 X-Git-Tag: v0.28.20240811150311 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=11c1a3a65a190c99b32546cc76f6621b2a52da54;p=part%2F.git 1 --- diff --git a/websocket/Client.go b/websocket/Client.go index 3608ca4..543c3b2 100644 --- a/websocket/Client.go +++ b/websocket/Client.go @@ -57,14 +57,15 @@ func New_client(config *Client) (*Client, error) { WTOMs: 300 * 1000, Func_normal_close: func() {}, Func_abort_close: func() {}, + BufSize: 10, msg: msgq.NewType[*WsMsg](), } tmp.Url = config.Url if tmp.Url == "" { return nil, errors.New(`url == ""`) } - if v := config.BufSize; v <= 1 { - tmp.BufSize = 1 + if v := config.BufSize; v >= 1 { + tmp.BufSize = v } if v := config.TO; v != 0 { tmp.RTOMs = v @@ -166,11 +167,11 @@ func (o *Client) Handle() (*msgq.MsgType[*WsMsg], error) { if msg, e := pio.ReadAll(r, buf); e != nil { err = e } else { - msgs[cuP] = append(msgs[cuP][:0], msg...) cuP++ if cuP >= o.BufSize { cuP = 0 } + msgs[cuP] = append(msgs[cuP][:0], msg...) } } if err != nil {