Skip to content

Commit

Permalink
chore: add ping Handler DEBUG log in msgGateway. (#2415)
Browse files Browse the repository at this point in the history
* chore: add  ping Handler debug log in mgsGateway.

* update log print content.

* update pingHandler method send args.
  • Loading branch information
mo3et authored Jul 17, 2024
1 parent dcc0b57 commit 42a66cf
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/msggateway/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,14 @@ func (c *Client) ResetClient(ctx *UserConnContext, conn LongConn, longConnServer
c.hbCtx, c.hbCancel = context.WithCancel(c.ctx)
}

func (c *Client) pingHandler(_ string) error {
func (c *Client) pingHandler(appData string) error {
if err := c.conn.SetReadDeadline(pongWait); err != nil {
return err
}

return c.writePongMsg()
log.ZDebug(c.ctx, "ping Handler Success.", "appData", appData)

return c.writePongMsg(appData)
}

func (c *Client) pongHandler(_ string) error {
Expand Down Expand Up @@ -156,7 +158,7 @@ func (c *Client) readMessage() {
return

case PingMessage:
err := c.writePongMsg()
err := c.writePongMsg("")
log.ZError(c.ctx, "writePongMsg", err)

case CloseMessage:
Expand Down Expand Up @@ -378,7 +380,7 @@ func (c *Client) writePingMsg() error {
return c.conn.WriteMessage(PingMessage, nil)
}

func (c *Client) writePongMsg() error {
func (c *Client) writePongMsg(appData string) error {
if c.closed.Load() {
return nil
}
Expand All @@ -391,5 +393,5 @@ func (c *Client) writePongMsg() error {
return err
}

return c.conn.WriteMessage(PongMessage, nil)
return c.conn.WriteMessage(PongMessage, []byte(appData))
}

0 comments on commit 42a66cf

Please sign in to comment.