From: Sergey Matveev Date: Mon, 29 Apr 2024 11:18:55 +0000 (+0300) Subject: Shorter flags X-Git-Tag: v3.0.0^0 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=20ae51dabb3dbad2e1a0d89a736daa0150439762e664c5873be6484e2058e2b0;p=vors.git Shorter flags --- diff --git a/cmd/client/main.go b/cmd/client/main.go index 00ccce1..023303a 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -116,9 +116,10 @@ Press F10 to quit. Each peer contains various statistics: number of packets received from it (or sent, if it is you), traffic amount, number of silence seconds, number of bad packets (malformed or altered, number of lost packets, -number of reordered packets. "TALK" means that recently an audio packet -was received. "MUTE" means that peer is in muted mode. "SILENT" means -that peer is locally muted.`) +number of reordered packets. +Gree "T" means that recently an audio packet was received. +Red "MUTE" means that peer is in muted mode. +Magenta "S" means that peer is locally muted.`) } flag.Parse() log.SetFlags(log.Lmicroseconds) diff --git a/cmd/client/stats.go b/cmd/client/stats.go index 985c3ae..56200c8 100644 --- a/cmd/client/stats.go +++ b/cmd/client/stats.go @@ -64,7 +64,7 @@ func statsDrawer(s *Stream) { return case now = <-tick: l := fmt.Sprintf( - "%s | %s | S/B/L/R: %s/%s/%s/%s", + " %s | %s | S/B/L/R: %s/%s/%s/%s", humanize.Comma(s.stats.pkts), humanize.IBytes(s.stats.bytes), humanize.Comma(int64(s.actr-(s.ctr&0x00FFFF))/50), @@ -72,19 +72,21 @@ func statsDrawer(s *Stream) { humanize.Comma(s.stats.lost), humanize.Comma(s.stats.reorder), ) + peerFlags := []string{" ", " ", " "} if s.name == *Name && Muted { - l += " | " + vors.CRed + "MUTE" + vors.CReset + peerFlags[0] = vors.CRed + "M" + vors.CReset } else { if s.silenced { - l += " | " + vors.CMagenta + "SILENT" + vors.CReset + peerFlags[2] = vors.CMagenta + "S" + vors.CReset } if s.stats.last.Add(vors.ScreenRefresh).After(now) { - l += " | " + vors.CGreen + "TALK" + vors.CReset + peerFlags[1] = vors.CGreen + "T" + vors.CReset } if s.muted { - l += " | " + vors.CRed + "MUTE" + vors.CReset + peerFlags[0] = vors.CRed + "M" + vors.CReset } } + l = strings.Join(peerFlags, "") + l v, err = GUI.View(s.name) if err == nil { v.Clear() diff --git a/cmd/server/main.go b/cmd/server/main.go index b102cfd..82008ca 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -380,8 +380,9 @@ List of known rooms is shown by default. If room requires password authentication, then "protected" is written nearby. Each room's member username and IP address is shown, together with various statistics: number of received, transmitted packets, number of bad packets (failed -authentication), amount of traffic. "TALK" means that recently an audio -packet was received. "MUTE" means that peer is in muted mode. +authentication), amount of traffic. +Green "T" means that recently an audio packet was received. +Red "M" means that peer is in muted mode. Press F10 to quit.`) } flag.Parse() diff --git a/cmd/server/room.go b/cmd/server/room.go index 1d924fc..78a79bc 100644 --- a/cmd/server/room.go +++ b/cmd/server/room.go @@ -3,6 +3,7 @@ package main import ( "fmt" "sort" + "strings" "sync" "time" @@ -37,8 +38,9 @@ func (room *Room) Stats(now time.Time) []string { if peer == nil { continue } + peerFlags := []string{" ", " "} line := fmt.Sprintf( - "%12s | %s | Rx/Tx/Bad: %s / %s / %s | %s / %s", + "%10s | %s | Rx/Tx/Bad: %s / %s / %s | %s / %s", peer.name, peer.addr, humanize.Comma(peer.stats.pktsRx), @@ -48,12 +50,12 @@ func (room *Room) Stats(now time.Time) []string { humanize.IBytes(peer.stats.bytesTx), ) if peer.muted { - line += " | " + vors.CRed + "MUTE" + vors.CReset + peerFlags[0] = vors.CRed + "M" + vors.CReset } if peer.stats.last.Add(vors.ScreenRefresh).After(now) { - line += " | " + vors.CGreen + "TALK" + vors.CReset + peerFlags[1] = vors.CGreen + "T" + vors.CReset } - lines = append(lines, line) + lines = append(lines, strings.Join(peerFlags, "")+line) } return lines }