This commit is contained in:
esrrhs 2018-12-19 15:58:58 +08:00
parent c08c32bd03
commit 3241a745e7
2 changed files with 7 additions and 3 deletions

View File

@ -112,12 +112,16 @@ func (p *Client) Run() {
interval := time.NewTicker(time.Second)
defer interval.Stop()
intervalPing := time.NewTicker(time.Second * 10)
defer interval.Stop()
for {
select {
case <-interval.C:
p.checkTimeoutConn()
p.ping()
p.showNet()
case <-intervalPing.C:
p.ping()
case r := <-recv:
p.processPacket(r)
}
@ -230,7 +234,7 @@ func (p *Client) ping() {
}
func (p *Client) showNet() {
fmt.Printf("send %dPacket/s %dKB/s recv %dPacket/s %dKB/s\n", p.sendPacket, p.sendPacket/1024, p.recvPacket, p.recvPacket/1024)
fmt.Printf("send %dPacket/s %dKB/s recv %dPacket/s %dKB/s\n", p.sendPacket, p.sendPacketSize/1024, p.recvPacket, p.recvPacketSize/1024)
p.sendPacket = 0
p.recvPacket = 0
p.sendPacketSize = 0

View File

@ -169,7 +169,7 @@ func (p *Server) checkTimeoutConn() {
}
func (p *Server) showNet() {
fmt.Printf("send %dPacket/s %dKB/s recv %dPacket/s %dKB/s\n", p.sendPacket, p.sendPacket/1024, p.recvPacket, p.recvPacket/1024)
fmt.Printf("send %dPacket/s %dKB/s recv %dPacket/s %dKB/s\n", p.sendPacket, p.sendPacketSize/1024, p.recvPacket, p.recvPacketSize/1024)
p.sendPacket = 0
p.recvPacket = 0
p.sendPacketSize = 0