Use server counters for user statistics
This commit is contained in:
committed by
Brandon McGinty
parent
cb0951dee8
commit
82440b7670
@@ -1239,13 +1239,13 @@ func (c *Client) handleUserStats(buffer []byte) error {
|
||||
if packet.FromServer.Good != nil {
|
||||
stats.FromServer.Good = *packet.FromServer.Good
|
||||
}
|
||||
if packet.FromClient.Late != nil {
|
||||
if packet.FromServer.Late != nil {
|
||||
stats.FromServer.Late = *packet.FromServer.Late
|
||||
}
|
||||
if packet.FromClient.Lost != nil {
|
||||
if packet.FromServer.Lost != nil {
|
||||
stats.FromServer.Lost = *packet.FromServer.Lost
|
||||
}
|
||||
if packet.FromClient.Resync != nil {
|
||||
if packet.FromServer.Resync != nil {
|
||||
stats.FromServer.Resync = *packet.FromServer.Resync
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package gumble
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.stormux.org/storm/barnard/gumble/gumble/MumbleProto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// Regression: FromServer loss counters were accidentally copied from
|
||||
// FromClient, hiding the server-to-client packet-loss condition.
|
||||
func TestUserStatsUsesFromServerCounters(t *testing.T) {
|
||||
c := &Client{Config: NewConfig(), Users: make(Users)}
|
||||
u := c.Users.create(7)
|
||||
session := uint32(7)
|
||||
clientLate, serverLate := uint32(1), uint32(9)
|
||||
data, _ := proto.Marshal(&MumbleProto.UserStats{Session: &session,
|
||||
FromClient: &MumbleProto.UserStats_Stats{Late: &clientLate},
|
||||
FromServer: &MumbleProto.UserStats_Stats{Late: &serverLate}})
|
||||
if err := c.handleUserStats(data); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if u.Stats.FromServer.Late != serverLate {
|
||||
t.Fatalf("got %d, want %d", u.Stats.FromServer.Late, serverLate)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user