Skip to content

Commit

Permalink
test: for pressure test.
Browse files Browse the repository at this point in the history
Signed-off-by: Gordon <[email protected]>
  • Loading branch information
FGadvancer committed Sep 8, 2023
1 parent a9bc24d commit 8b34d36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions internal/msggateway/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const (
PongMessage = 10
)

type PongHandler func(string) error
type PingPongHandler func(string) error

type Client struct {
w *sync.Mutex
Expand Down Expand Up @@ -107,7 +107,7 @@ func (c *Client) ResetClient(
c.token = token
}

func (c *Client) pongHandler(_ string) error {
func (c *Client) pingHandler(_ string) error {
c.conn.SetReadDeadline(pongWait)
return nil
}
Expand All @@ -122,7 +122,7 @@ func (c *Client) readMessage() {
}()
c.conn.SetReadLimit(maxMessageSize)
_ = c.conn.SetReadDeadline(pongWait)
c.conn.SetPongHandler(c.pongHandler)
c.conn.SetPingHandler(c.pingHandler)
for {
messageType, message, returnErr := c.conn.ReadMessage()
if returnErr != nil {
Expand Down
8 changes: 6 additions & 2 deletions internal/msggateway/long_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ type LongConn interface {
SetConnNil()
// SetReadLimit sets the maximum size for a message read from the peer.bytes
SetReadLimit(limit int64)
SetPongHandler(handler PongHandler)
SetPongHandler(handler PingPongHandler)
SetPingHandler(handler PingPongHandler)
// GenerateLongConn Check the connection of the current and when it was sent are the same
GenerateLongConn(w http.ResponseWriter, r *http.Request) error
}
Expand Down Expand Up @@ -116,9 +117,12 @@ func (d *GWebSocket) SetReadLimit(limit int64) {
d.conn.SetReadLimit(limit)
}

func (d *GWebSocket) SetPongHandler(handler PongHandler) {
func (d *GWebSocket) SetPongHandler(handler PingPongHandler) {
d.conn.SetPongHandler(handler)
}
func (d *GWebSocket) SetPingHandler(handler PingPongHandler) {
d.conn.SetPingHandler(handler)
}

//func (d *GWebSocket) CheckSendConnDiffNow() bool {
// return d.conn == d.sendConn
Expand Down

0 comments on commit 8b34d36

Please sign in to comment.