mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-05-04 23:03:09 +02:00
Add callback on received RTT.
This commit is contained in:
parent
f4d4d5fb4d
commit
acbb47a100
|
@ -90,6 +90,7 @@ type Client struct {
|
||||||
OnLookupCountry func(*Client) string
|
OnLookupCountry func(*Client) string
|
||||||
OnClosed func(*Client)
|
OnClosed func(*Client)
|
||||||
OnMessageReceived func(*Client, []byte)
|
OnMessageReceived func(*Client, []byte)
|
||||||
|
OnRTTReceived func(*Client, time.Duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(conn *websocket.Conn, remoteAddress string, agent string) (*Client, error) {
|
func NewClient(conn *websocket.Conn, remoteAddress string, agent string) (*Client, error) {
|
||||||
|
@ -110,6 +111,7 @@ func NewClient(conn *websocket.Conn, remoteAddress string, agent string) (*Clien
|
||||||
OnLookupCountry: func(client *Client) string { return unknownCountry },
|
OnLookupCountry: func(client *Client) string { return unknownCountry },
|
||||||
OnClosed: func(client *Client) {},
|
OnClosed: func(client *Client) {},
|
||||||
OnMessageReceived: func(client *Client, data []byte) {},
|
OnMessageReceived: func(client *Client, data []byte) {},
|
||||||
|
OnRTTReceived: func(client *Client, rtt time.Duration) {},
|
||||||
}
|
}
|
||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
@ -234,6 +236,7 @@ func (c *Client) ReadPump() {
|
||||||
} else {
|
} else {
|
||||||
log.Printf("Client from %s has RTT of %d ms (%s)", addr, rtt_ms, rtt)
|
log.Printf("Client from %s has RTT of %d ms (%s)", addr, rtt_ms, rtt)
|
||||||
}
|
}
|
||||||
|
c.OnRTTReceived(c, rtt)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue