add
This commit is contained in:
parent
c08c32bd03
commit
3241a745e7
@ -112,12 +112,16 @@ func (p *Client) Run() {
|
|||||||
interval := time.NewTicker(time.Second)
|
interval := time.NewTicker(time.Second)
|
||||||
defer interval.Stop()
|
defer interval.Stop()
|
||||||
|
|
||||||
|
intervalPing := time.NewTicker(time.Second * 10)
|
||||||
|
defer interval.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-interval.C:
|
case <-interval.C:
|
||||||
p.checkTimeoutConn()
|
p.checkTimeoutConn()
|
||||||
p.ping()
|
|
||||||
p.showNet()
|
p.showNet()
|
||||||
|
case <-intervalPing.C:
|
||||||
|
p.ping()
|
||||||
case r := <-recv:
|
case r := <-recv:
|
||||||
p.processPacket(r)
|
p.processPacket(r)
|
||||||
}
|
}
|
||||||
@ -230,7 +234,7 @@ func (p *Client) ping() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Client) showNet() {
|
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.sendPacket = 0
|
||||||
p.recvPacket = 0
|
p.recvPacket = 0
|
||||||
p.sendPacketSize = 0
|
p.sendPacketSize = 0
|
||||||
|
@ -169,7 +169,7 @@ func (p *Server) checkTimeoutConn() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Server) showNet() {
|
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.sendPacket = 0
|
||||||
p.recvPacket = 0
|
p.recvPacket = 0
|
||||||
p.sendPacketSize = 0
|
p.sendPacketSize = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user