mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-05-17 04:56:33 +02:00
commit
3b26003b12
20
client.go
20
client.go
|
@ -99,6 +99,7 @@ type Client struct {
|
||||||
agent string
|
agent string
|
||||||
closed uint32
|
closed uint32
|
||||||
country *string
|
country *string
|
||||||
|
logRTT bool
|
||||||
|
|
||||||
session unsafe.Pointer
|
session unsafe.Pointer
|
||||||
|
|
||||||
|
@ -125,9 +126,10 @@ func NewClient(conn *websocket.Conn, remoteAddress string, agent string) (*Clien
|
||||||
agent = "unknown user agent"
|
agent = "unknown user agent"
|
||||||
}
|
}
|
||||||
client := &Client{
|
client := &Client{
|
||||||
conn: conn,
|
conn: conn,
|
||||||
addr: remoteAddress,
|
addr: remoteAddress,
|
||||||
agent: agent,
|
agent: agent,
|
||||||
|
logRTT: true,
|
||||||
|
|
||||||
closeChan: make(chan bool, 1),
|
closeChan: make(chan bool, 1),
|
||||||
messageChan: make(chan *bytes.Buffer, 16),
|
messageChan: make(chan *bytes.Buffer, 16),
|
||||||
|
@ -272,11 +274,13 @@ func (c *Client) ReadPump() {
|
||||||
}
|
}
|
||||||
if ts, err := strconv.ParseInt(msg, 10, 64); err == nil {
|
if ts, err := strconv.ParseInt(msg, 10, 64); err == nil {
|
||||||
rtt := now.Sub(time.Unix(0, ts))
|
rtt := now.Sub(time.Unix(0, ts))
|
||||||
rtt_ms := rtt.Nanoseconds() / time.Millisecond.Nanoseconds()
|
if c.logRTT {
|
||||||
if session := c.GetSession(); session != nil {
|
rtt_ms := rtt.Nanoseconds() / time.Millisecond.Nanoseconds()
|
||||||
log.Printf("Client %s has RTT of %d ms (%s)", session.PublicId(), rtt_ms, rtt)
|
if session := c.GetSession(); session != nil {
|
||||||
} else {
|
log.Printf("Client %s has RTT of %d ms (%s)", session.PublicId(), rtt_ms, rtt)
|
||||||
log.Printf("Client from %s has RTT of %d ms (%s)", addr, rtt_ms, rtt)
|
} else {
|
||||||
|
log.Printf("Client from %s has RTT of %d ms (%s)", addr, rtt_ms, rtt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c.OnRTTReceived(c, rtt)
|
c.OnRTTReceived(c, rtt)
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,8 @@ const (
|
||||||
maxWaitDelay = 8 * time.Second
|
maxWaitDelay = 8 * time.Second
|
||||||
|
|
||||||
defaultProxyTimeoutSeconds = 2
|
defaultProxyTimeoutSeconds = 2
|
||||||
|
|
||||||
|
rttLogDuration = 500 * time.Millisecond
|
||||||
)
|
)
|
||||||
|
|
||||||
type mcuProxyPubSubCommon struct {
|
type mcuProxyPubSubCommon struct {
|
||||||
|
@ -385,8 +387,10 @@ func (c *mcuProxyConnection) readPump() {
|
||||||
}
|
}
|
||||||
if ts, err := strconv.ParseInt(msg, 10, 64); err == nil {
|
if ts, err := strconv.ParseInt(msg, 10, 64); err == nil {
|
||||||
rtt := now.Sub(time.Unix(0, ts))
|
rtt := now.Sub(time.Unix(0, ts))
|
||||||
rtt_ms := rtt.Nanoseconds() / time.Millisecond.Nanoseconds()
|
if rtt >= rttLogDuration {
|
||||||
log.Printf("Proxy at %s has RTT of %d ms (%s)", c.url, rtt_ms, rtt)
|
rtt_ms := rtt.Nanoseconds() / time.Millisecond.Nanoseconds()
|
||||||
|
log.Printf("Proxy at %s has RTT of %d ms (%s)", c.url, rtt_ms, rtt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue