|
@@ -2,6 +2,7 @@ package ws
|
|
|
|
|
|
import (
|
|
|
"errors"
|
|
|
+ "fmt"
|
|
|
"github.com/gorilla/websocket"
|
|
|
"sync"
|
|
|
"time"
|
|
@@ -87,6 +88,7 @@ func SetupLatencyMeasurement(conn *websocket.Conn) *LatencyMeasurer {
|
|
|
lm := NewLatencyMeasurer(5) // 使用最近5次测量的滑动窗口
|
|
|
conn.SetPongHandler(func(appData string) error {
|
|
|
lm.CalculateLatency()
|
|
|
+ fmt.Printf("触发了pong的应答")
|
|
|
return nil
|
|
|
})
|
|
|
return lm
|