test: for pressure test.

Signed-off-by: Gordon <46924906+FGadvancer@users.noreply.github.com>
pull/1101/head
Gordon 2 years ago
parent a9bc24dca0
commit 8b34d3695e

@ -59,7 +59,7 @@ const (
PongMessage = 10
)
type PongHandler func(string) error
type PingPongHandler func(string) error
type Client struct {
w *sync.Mutex
@ -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
}
@ -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 {

@ -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
}
@ -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

Loading…
Cancel
Save