Skip to content

Commit

Permalink
新增:ReceiverMessageFunc,实现:客户端连接后,客户端每发一次消息,服务端持续返回新的消息
Browse files Browse the repository at this point in the history
  • Loading branch information
steden committed Sep 4, 2024
1 parent 280fb8e commit 475279b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ func (receiver *Client) Connect() error {
return err
}

// ReceiverJson 接收消息(并反序列化成val)
func (receiver *Client) ReceiverJson(val any) error {
// Receiver 接收消息(并反序列化成val)
func (receiver *Client) Receiver(val any) error {
retMsg := make([]byte, receiver.msgBufferSize)
n, err := receiver.conn.Read(retMsg)
if err != nil {
Expand All @@ -80,8 +80,8 @@ func (receiver *Client) ReceiverJson(val any) error {
return json.Unmarshal(retMsg[:n], val)
}

// Receiver 接收消息
func (receiver *Client) Receiver() (string, error) {
// ReceiverMessage 接收消息
func (receiver *Client) ReceiverMessage() (string, error) {
var retMsg = make([]byte, receiver.msgBufferSize)
n, err := receiver.conn.Read(retMsg)
if err != nil {
Expand Down

0 comments on commit 475279b

Please sign in to comment.