Пример #1
0
func (this *BaseProtocolTcpClient) doPing() {
	timer.CancelInaccuracyTimer(this.ping_timer_id)
	timer.NewInaccuracyTimerCallback(this.ping_interval, func(id int64) {
		this.ping_timer_id = id
	}, func(time int64) {
		if time != 0 {
			log.I_NET(this.client.GetConnection().LocalAddr(), " write to ", this.client.GetConnection().RemoteAddr(), ", data : ping")
			this.Write(protocol.NewPingProtocol(this.entity.ID))
		}
	})
}
Пример #2
0
func (this *BaseClient) doPing() {
	timer.CancelInaccuracyTimer(this.ping_timer_id)
	timer.NewInaccuracyTimerCallback(this.ping_interval, func(id int64) {
		this.ping_timer_id = id
	}, func(time int64) {
		if time != 0 {
			log.I_NET(this.conn.LocalAddr(), " write to ", this.conn.RemoteAddr(), ", data : ping")
			this.Write(protocol.NewPingProtocol(this.id), nil)
			this.doPing()
		}
	})
}