// PeriodicSend periodically send a request at every timer tick
// the sending can be stopped using the channel given
PeriodicSend periodically send a request at every timer tick
the sending can be stopped using the channel given
// PeriodicSend periodically send a request at every timer tick // the sending can be stopped using the channel given
func (c *Connection) PeriodicSend(packet *Packet, closeChannel chan bool, timer uint64) {
	err := c.Send(packet)
	if err != nil && debug {
		log.Printf("Error while sending request to %s: %s", c.Conn.RemoteAddr().String(), err)
	}
	repeatTimer := time.NewTicker(time.Duration(timer) * time.Second)
	defer repeatTimer.Stop()
	for {
		select {
		case status := <-closeChannel:
			if status {
				c.Close()
			}
			return
		case <-repeatTimer.C:
			err := c.Send(packet)
			if err != nil && debug {
				log.Printf("Error while repeating request to %s: %s", c.Conn.RemoteAddr().String(), err)
			}
		}
	}
}
func ( c * Connection ) PeriodicSend ( packet * Packet , closeChannel chan bool , timer uint64 ) { err := c . Send ( packet ) if err != nil && debug { log . Printf ( " " , c . Conn . RemoteAddr ( ) . String ( ) , err ) } repeatTimer := time . NewTicker ( time . Duration ( timer ) * time . Second ) defer repeatTimer . Stop ( ) for { select { case status := <- closeChannel : if status { c . Close ( ) } return case <- repeatTimer . C : err := c . Send ( packet ) if err != nil && debug { log . Printf ( " " , c . Conn . RemoteAddr ( ) . String ( ) , err ) } } } }
PeriodicSend periodically send a request at every timer tick
the sending can be stopped using the channel given
PeriodicSend periodically send a request at every timer tick the sending can be stopped using the channel given
// start timer for repeating request to validator // stop because we received the packet from validator // repeat request